Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 106 lines (65 sloc) 2.789 kB
f37191b @yojimbo87 Fixed:
yojimbo87 authored
1 LoveSeat
2 ========
3
1b87198 @yojimbo87 Readme usage update.
yojimbo87 authored
4 Love Seat is a simply architected [CouchDB](http://couchdb.apache.org/) C# client with the
f37191b @yojimbo87 Fixed:
yojimbo87 authored
5 intent to abstract away just enough so that it's easy to use, but not enough so that you
4216640 @soitgoes updated README for MonoDroid Support
authored
6 don't know what's going on. LoveSeat will not introduce unneeded dependancies and will
7 attempt to remove programmer burden while leaving you close enough to the metal that you are
8 able to utilize the full featureset of CouchDb.
f37191b @yojimbo87 Fixed:
yojimbo87 authored
9
10
11 Tested compatibility
12 ====================
13
14 * CouchDB 1.0.1
4216640 @soitgoes updated README for MonoDroid Support
authored
15 * .NET Framework 3.5, 4.0 or Mono 2.9 (compiled master branch from Nov 20 2010), and MonoDroid
01afad0 @soitgoes Enhanced the Readme
authored
16
17
1b87198 @yojimbo87 Readme usage update.
yojimbo87 authored
18 LoveSeat usage
19 ==============
01afad0 @soitgoes Enhanced the Readme
authored
20
1b87198 @yojimbo87 Readme usage update.
yojimbo87 authored
21 **Basics**
3b59654 @soitgoes Markdown touchup
authored
22
1b87198 @yojimbo87 Readme usage update.
yojimbo87 authored
23 // assumes localhost:5984 with no credentials if constructor is left blank
24 var client = new CouchClient();
3b59654 @soitgoes Markdown touchup
authored
25 var db= client.GetDatabase("Northwind");
26
1b87198 @yojimbo87 Readme usage update.
yojimbo87 authored
27 // set default design doc (not required)
28 db.SetDefaultDesignDoc("docs");
29
30 // get document by ID
31 Document myDoc = db.GetDocument("12345");
3b59654 @soitgoes Markdown touchup
authored
32
1b87198 @yojimbo87 Readme usage update.
yojimbo87 authored
33 // get document by ID (strongly typed POCO version)
34 MyObject myObj = db.GetDocument<MyObject>("12345");
3b59654 @soitgoes Markdown touchup
authored
35
1b87198 @yojimbo87 Readme usage update.
yojimbo87 authored
36 **Simple view results**
3b59654 @soitgoes Markdown touchup
authored
37
1b87198 @yojimbo87 Readme usage update.
yojimbo87 authored
38 // get view results
5105fe3 @soitgoes Markdown touchup
authored
39 var results = db.View<MyObject>("view_name");
3b59654 @soitgoes Markdown touchup
authored
40
1b87198 @yojimbo87 Readme usage update.
yojimbo87 authored
41 // get view results with parameters
42 var options = new ViewOptions();
43 options.StartKey.Add("Atlanta");
44 options.EndKey.Add("Washington");
3b59654 @soitgoes Markdown touchup
authored
45
1b87198 @yojimbo87 Readme usage update.
yojimbo87 authored
46 var results = db.View<MyObject>("view_name", options);
3b59654 @soitgoes Markdown touchup
authored
47
1b87198 @yojimbo87 Readme usage update.
yojimbo87 authored
48 // loop through strongly typed results
3b59654 @soitgoes Markdown touchup
authored
49 foreach (var item in results.Items){
f37191b @yojimbo87 Fixed:
yojimbo87 authored
50 // do something
3b59654 @soitgoes Markdown touchup
authored
51
52 }
1b87198 @yojimbo87 Readme usage update.
yojimbo87 authored
53
54 **Generating more complex view parameters**
55
56 var options = new ViewOptions();
57 // generate ["foo"] startkey parameter
58 options.StartKey.Add("foo");
59 // generate ["foo",{},{}] endkey parameter
60 options.EndKey.Add("foo", CouchValue.Empty, CouchValue.Empty);
61
62 var results = db.View<MyObject>("view_name", options);
63
64 // loop through strongly typed results
65 foreach (var item in results.Items){
66 // do something
f37191b @yojimbo87 Fixed:
yojimbo87 authored
67
1b87198 @yojimbo87 Readme usage update.
yojimbo87 authored
68 }
f37191b @yojimbo87 Fixed:
yojimbo87 authored
69
1b87198 @yojimbo87 Readme usage update.
yojimbo87 authored
70 **Customized view key parameters**
71
72 Assuming that view keys have complex structure, for example:
f706dbb @yojimbo87 Small readme fix.
yojimbo87 authored
73
f37191b @yojimbo87 Fixed:
yojimbo87 authored
74 ["johny", ["work", "programming"]]
75
76 ["joe", ["programming"]]
77
78 ["johny", ["work"]]
79
80 using Newtonsoft.Json.Linq;
81
82 ...
83
1b87198 @yojimbo87 Readme usage update.
yojimbo87 authored
84 var options = new ViewOptions();
f37191b @yojimbo87 Fixed:
yojimbo87 authored
85 options.StartKey.Add(new JRaw("[\"johny\",[\"work\"]"));
4e1e7fb @soitgoes Improved view option syntax.
authored
86 options.EndKey.Add(new JRaw("[\"johny\",[\"work\",{}]]"));
87
1b87198 @yojimbo87 Readme usage update.
yojimbo87 authored
88 var results = db.View<MyObject>("view_name", options);
f37191b @yojimbo87 Fixed:
yojimbo87 authored
89
90 foreach (var item in results.Items){
91 // do something
92
93 }
94
95 This example will return only rows where first key contains "johny" and second key
96 contains "work".
97
3b59654 @soitgoes Markdown touchup
authored
98 **Get the results of a List**
99
100 var results = db.List("list_name")
01afad0 @soitgoes Enhanced the Readme
authored
101
1b87198 @yojimbo87 Readme usage update.
yojimbo87 authored
102 LoveSeat supports replication and user management off of the CouchClient as well. Enjoy!
01afad0 @soitgoes Enhanced the Readme
authored
103
104
3b59654 @soitgoes Markdown touchup
authored
105
Something went wrong with that request. Please try again.