Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Readme usage update.

  • Loading branch information...
commit 1b87198753f5ca78b818cf213ea469b2740bb993 1 parent 1fdc2fd
@yojimbo87 yojimbo87 authored
Showing with 43 additions and 33 deletions.
  1. +43 −33 README.md
View
76 README.md
@@ -1,7 +1,7 @@
LoveSeat
========
-Love Seat is a simply architected [CouchDB](http://couchdb.apache.org/) wrapper with the
+Love Seat is a simply architected [CouchDB](http://couchdb.apache.org/) 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.
@@ -10,46 +10,64 @@ Tested compatibility
====================
* CouchDB 1.0.1
- * .NET 4.0 Framework
- * Mono 2.9 (compiled master branch form Nov 20 2010)
+ * .NET Framework 4.0 or Mono 2.9 (compiled master branch from Nov 20 2010)
-LoveSeat Basics
-===============
+LoveSeat usage
+==============
-**Everything in LoveSeat starts with a CouchClient.**
-
- var client = new CouchClient(); // assumes localhost:5984 with no credentials if left blank
-
-**From here you can get the database**
+**Basics**
+ // assumes localhost:5984 with no credentials if constructor is left blank
+ var client = new CouchClient();
var db= client.GetDatabase("Northwind");
- // Set the default design doc (not required and can be overriden)
- db.SetDefaultDesignDoc("foo");
+ // set default design doc (not required)
+ db.SetDefaultDesignDoc("docs");
+
+ // get document by ID
+ Document myDoc = db.GetDocument("12345");
- // Get a Document By Id
- db.GetDocument("12345");
+ // get document by ID (strongly typed POCO version)
+ MyObject myObj = db.GetDocument<MyObject>("12345");
-**Get a view results and populate your Domain object**
+**Simple view results**
+ // get view results
var results = db.View<MyObject>("view_name");
- // ...or with parameters
- var options = new ViewOptions{Limit=10};
- options.StartKey.Add("abc");
- results = db.View<MyObject>("view_name", options);
+ // get view results with parameters
+ var options = new ViewOptions();
+ options.StartKey.Add("Atlanta");
+ options.EndKey.Add("Washington");
- // loop through your strongly typed results
+ 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
-**Get a view results and with more complex key parameters**
+ }
-Assuming that your view keys have complex structure, for example:
+**Customized view key parameters**
+
+Assuming that view keys have complex structure, for example:
["johny", ["work", "programming"]]
@@ -61,18 +79,11 @@ Assuming that your view keys have complex structure, for example:
...
- var options = new ViewOptions();
-
- options.StartKey.Add("1234", CouchValue.Empty); // passes "[1234, {}]"
- options.EndKey.Add("1234", DateTime.Now.AddYears(1)); //Dates are properly converted to ISO8601
-
- // or if you would like to do all the work and create the json yourself...
+ var options = new ViewOptions();
options.StartKey.Add(new JRaw("[\"johny\",[\"work\"]"));
options.EndKey.Add(new JRaw("[\"johny\",[\"work\",{}]]"));
- results = db.View<MyObject>("view_name", options);
-
- // loop through your strongly typed results
+ var results = db.View<MyObject>("view_name", options);
foreach (var item in results.Items){
// do something
@@ -82,12 +93,11 @@ Assuming that your view keys have complex structure, for example:
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!
+LoveSeat supports replication and user management off of the CouchClient as well. Enjoy!
Please sign in to comment.
Something went wrong with that request. Please try again.