Skip to content
Bringing CouchDB and .NET little closer
C#
Failed to load latest commit information.
Libraries
LoveSeat.DesignDoc DesignDoc Updater Added Feb 2, 2016
LoveSeat.DocUpdater
LoveSeat.IntegrationTest Include in output Feb 2, 2016
LoveSeat.Interfaces Find with string id May 22, 2015
LoveSeat.Monodroid Got Monodroid build compiled Jul 26, 2012
LoveSeat.Repository Find with string id May 22, 2015
LoveSeat Merge branch 'master' of github.com:soitgoes/LoveSeat Mar 29, 2016
packages fixed the LoveSeat csproj file Feb 27, 2015
.gitignore Upgraded Newtonsoft Jan 18, 2012
LICENSE Added MIT license. Dec 16, 2010
LoveSeat.Monodroid.sln Got Monodroid build compiled Jul 27, 2012
LoveSeat.sln DesignDoc Updater Added Feb 2, 2016
LoveSeatIde.vssettings Added IDE settings. Aug 11, 2013
README.md updated README for MonoDroid Support Jul 28, 2012

README.md

LoveSeat

Love Seat is a simply architected CouchDB C# client with the intent to abstract away just enough so that it's easy to use, but not enough so that you don't know what's going on. LoveSeat will not introduce unneeded dependancies and will attempt to remove programmer burden while leaving you close enough to the metal that you are able to utilize the full featureset of CouchDb.

Tested compatibility

  • CouchDB 1.0.1
  • .NET Framework 3.5, 4.0 or Mono 2.9 (compiled master branch from Nov 20 2010), and MonoDroid

LoveSeat usage

Basics

// assumes localhost:5984 with no credentials if constructor is left blank
var client = new CouchClient();
var db= client.GetDatabase("Northwind");

// set default design doc (not required)
db.SetDefaultDesignDoc("docs"); 

// get document by ID
Document myDoc = db.GetDocument("12345");

// get document by ID (strongly typed POCO version)
MyObject myObj = db.GetDocument<MyObject>("12345"); 

Simple view results

// get view results
var results = db.View<MyObject>("view_name");

// get view results with parameters
var options = new ViewOptions();
options.StartKey.Add("Atlanta");
options.EndKey.Add("Washington");

var results = db.View<MyObject>("view_name", options);

// loop through strongly typed results
foreach (var item in results.Items){ 
    // do something 

}

Generating more complex view parameters

var options = new ViewOptions();
// generate ["foo"] startkey parameter
options.StartKey.Add("foo");
// generate ["foo",{},{}] endkey parameter
options.EndKey.Add("foo", CouchValue.Empty, CouchValue.Empty);

var results = db.View<MyObject>("view_name", options);

// loop through strongly typed results
foreach (var item in results.Items){ 
    // do something 

}

Customized view key parameters

Assuming that view keys have complex structure, for example:

["johny", ["work", "programming"]]

["joe", ["programming"]]

["johny", ["work"]]

using Newtonsoft.Json.Linq;

...

var options = new ViewOptions(); 
options.StartKey.Add(new JRaw("[\"johny\",[\"work\"]"));
options.EndKey.Add(new JRaw("[\"johny\",[\"work\",{}]]"));  

var results = db.View<MyObject>("view_name", options);

foreach (var item in results.Items){ 
    // do something 

}

This example will return only rows where first key contains "johny" and second key contains "work".

Get the results of a List

var results = db.List("list_name")

LoveSeat supports replication and user management off of the CouchClient as well. Enjoy!

Something went wrong with that request. Please try again.