Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added more examples to readme.md

  • Loading branch information...
commit 69e54f7e7523bf61061e99715ea1405e5d71d16d 1 parent 1e960c4
@sergi authored
Showing with 28 additions and 0 deletions.
  1. +28 −0 readme.md
View
28 readme.md
@@ -44,4 +44,32 @@ Example usage
myDoc = coll.findOne();
print(myDoc);
+ // Now, lets add lots of little documents to the collection so we can explore queries and cursors
+ for (var i=0; i < 100; i++) {
+ coll.insert({"i": i});
+ }
+
+ print(coll.getCount());
+
+ // Let's get all the documents in the collection and print them out
+
+ var cur = coll.find();
+ while(cur.hasNext()) {
+ print(cur.next());
+ }
+
+ // Now use a query to get 1 document out
+
+ var query = { i: 71 };
+ cur = coll.find(query);
+
+ while(cur.hasNext())
+ print(cur.next());
+
+ // Now use a query to get a larger set
+
+ query = { "i": { "$gt": 50 } }; // i.e. find all where i > 50
+ cur = coll.find(query);
+ while(cur.hasNext())
+ print(cur.next());
Please sign in to comment.
Something went wrong with that request. Please try again.