MongoLab Query Parameters (Limit Skip)

Adding the skip and limit parameters of mongodb did not work from the MongoLab’s interface “{}, {}, 10, 20”; the equivalent of the following shell code:

db.users.find().skip(20).limit(10);
db.users.find({}, {}, 10, 20); // same as above, but less clear

My final objective was to use the skip and limit parameters in the REST; luckily these parameters where actually available in REST itself :

part of MongoLab’s REST API Doc
Resource URI Referencefull docs

/databases
GET – lists databases linked to the authenticated
account
/databases/
GET – lists sub-services for database
/databases//collections
GET – lists collections in database
/databases//collections/
GET – lists objects in collection
POST – inserts a new object into collection
/databases//collections//
GET – returns object with _id
PUT – modifies object (or creates if new)
DELETE – deletes object with _id
/databases//collections/?[q=][&c=true]
[&f=][&fo=true][&s=]
[&sk=][&l=]
GET – lists all objects matching these
optional params:
q: JSON queryreference
c: returns the result count for this query
f: set of fields to be returned in each object
(1—include; 0—exclude)
e.g. { “name” : 1, “email”: 1 } OR
e.g. { “comments” : 0 }
fo: return a single object from the result set
(same as ‘findOne()’ in the mongo shell)
s: sort order (1—asc; -1—desc)
i.e. { : }
sk: number of results to skip in the result set
l: limit for the number of results
/databases//collections/?[q=][&m=true]
[&u=true]
PUT – updates one or all objects matching the query.
payload should contain modifier operations
q: JSON queryreference
m: apply update to all objects in result set
(by default, only one is updated)
u: insert if none match the query (upsert)

 

keywords: number of records to return, rest mongodb pymongo mongolab skip limit mongdb limit

About Neil Rubens

see http://ActiveIntelligence.org

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*