Skip to content
kchodorow edited this page Sep 14, 2010 · 1 revision

Usage

http://localhost:27080/_batch

Description

Runs one or more database requests and returns all responses.

Request Type

POST

Required Arguments

  • 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.

Return Value

An array containing all responses. Each response is a JSON object.

Example

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}]
Clone this wiki locally