Just got a new NuGet out – “MyCouch – a Simple async CouchDb client for .Net” – which uses the async HTTP-client to interact with the HTTP API of CouchDb. It tries to mimic the domain-language and structure of CouchDb and lets you work with pure JSON or using entities/POCOs. The future will bring builtin support for caching, proxies/sharding, etc. Go grab it now and try it out. It’s on NuGet. Documentation is improved continuously.
It’s simple to get started with
install-package mycouch
using (var client = new Client("http://127.0.0.1:5984/test"))
{
//Consume here e.g
var response1 = client.Documents.Post(json);
//or using the async API
var response2 = client.Documents.PostAsync(json);
//Simple get
var getResponseOfJson = client.Documents.Get("someid");
var json = getResponseOfJson.Content;
//or using an entity
var getResponseOfEntity = client.Documents.Get<MyEntity>("someid");
//or querying using views
var viewResponse = client.Views.Query<MyEntity[]>(q => q
.StartKey("foo")
.EndKey("bar")
.Skip(2)
.Limit(5));
foreach (var myEntity in viewResponse.Rows) {
//Do something with your entity.
}
}
Every action will give you a response in turn. The response gives you information about state etc:
{
RequestUri: http://127.0.0.1:5984/test/1
RequestMethod: GET
Status: OK(200)
Error:<NULL>
Reason: <NULL>
Id: 1
Rev: 34-e0813c9f99766efcf679468adb02c6ce
Content: {
"_id":"1",
"_rev":"34-e0813c9f99766efcf679468adb02c6ce",
"$doctype":"artist",
"name":"Fake artist 1",
"albums":[{"name":"Greatest fakes #1"}]}
}
Well that’s it for now. More info will come.
//Daniel