'collection.all()' method fetches all the documents in a collection and return the cursor.
How to travers a cursor?
Using next(), hasNext() methods you can access the cursor elements.
Example
usersCursor = userCollection.all()
while(usersCursor.hasNext()) print(usersCursor.next())
127.0.0.1:8529@abc_org> usersCursor = userCollection.all() SimpleQueryAll(user) 127.0.0.1:8529@abc_org> while(usersCursor.hasNext()) print(usersCursor.next()) { "_key" : "12977", "_id" : "user/12977", "_rev" : "_cRdSijO---", "id" : 1, "firstName" : "Ram" } { "_key" : "13028", "_id" : "user/13028", "_rev" : "_cRdT1TK---", "id" : 514, "firstName" : "Sailu" } { "_key" : "14390", "_id" : "user/14390", "_rev" : "_cRd12pm---", "id" : 1, "firstName" : "Ram" } { "_key" : "14434", "_id" : "user/14434", "_rev" : "_cRd5IAm---", "lastName" : "Battu", "firstName" : "Ram" } 127.0.0.1:8529@abc_org>
No comments:
Post a Comment