forked from mongodb-labs/sleepy.mongoose
-
Notifications
You must be signed in to change notification settings - Fork 1
Batch Requests
kchodorow edited this page Sep 14, 2010
·
1 revision
http://localhost:27080/_batch
Runs one or more database requests and returns all responses.
POST
-
requests=array_of_requests
(array)
Each element of the array of requests is a JSON object representing a single request.
{
cmd : command_name,
[method : "GET"|"POST",]
[db : database_name,]
[collection : collection_name,]
[args : {
...
}]
}
method
defaults to GET.
An array containing all responses. Each response is a JSON object.
Connecting to a mongod server and running a query.
$ curl --data 'requests=[{"cmd":"_connect","method":"POST"},{"cmd":"_find","db":"x","collection":"y"}]' http://localhost:27080/_batch
[{"ok" : 1, "host" : "localhost", "port" : 27017, "name" : "default"},{"ok": 1, "results": [{"_id": {"$oid": "4bfad0483fb1ab0a59a47a00"}, "foo": "bar"}, {"_id": {"$oid": "4bfad0483fb1ab0a59a57a00"}, "foo": "bar"}, {"_id": {"$oid": "4bfad0483fb1ab0a59a67a00"}, "foo": "bar"}, {"_id": {"$oid": "4bfad0483fb1ab0a59a77a00"}, "foo": "bar"}, {"_id": {"$oid": "4bfad0483fb1ab0a59a87a00"}, "foo": "bar"}, {"_id": {"$oid": "4bfad0483fb1ab0a59a97a00"}, "foo": "bar"}, {"_id": {"$oid": "4bfad0483fb1ab0a59aa7a00"}, "foo": "bar"}, {"_id": {"$oid": "4bfad0483fb1ab0a59ab7a00"}, "foo": "bar"}, {"_id": {"$oid": "4bfad0483fb1ab0a59ac7a00"}, "foo": "bar"}, {"_id": {"$oid": "4bfad0483fb1ab0a59ad7a00"}, "foo": "bar"}], "id": 1}]