This repository has been archived by the owner on Dec 10, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 107
Querying
kchodorow edited this page Sep 24, 2012
·
3 revisions
http://localhost:27080/dbname/cname/_find
Query for documents. See also Getting More Results.
GET
-
criteria=search_criteria
(object) -
fields=fields_to_return
(object) -
sort=sort_fields
(object) -
skip=num
(number) -
limit=num
(number) explain=true
-
batch_size=num_to_return
(number)
{"ok" : 1, "results" : [{...}, ... ], "id" : cursor_id}
Find all documents in the foo.bar namespace.
$ curl -X GET 'http://localhost:27080/foo/bar/_find'
Find document with object id "4f8c6f05db61e2a72600001d".
$ curl -X GET 'http://localhost:27080/foo/bar/_find?criteria={"_id":{"$oid":"4f8c6f05db61e2a72600001d"}}'
Find all documents in the foo.bar namespace and sort by x descending
$ curl -X GET 'http://localhost:27080/foo/bar/_find?sort=%7B%22x%22%3A-1%7D'
Decoded, we're really requesting http://localhost:27080/foo/bar/_find?sort={"x":-1}
Find all documents in the foo.bar namespace with an x field matching /fo+/i
:
$ curl -X GET 'http://localhost:27080/foo/bar/_find?criteria=%7B%22x%22:%7B%22$regex%22:%22fo+%22,%22$options%22:%22i%22%7D%7D'
Decoded, this looks like: http://localhost:27080/foo/bar/_find?criteria={"x":{"$regex":"fo+","$options":"i"}}
.