Search…
HTTP Driver

POST /:object/db/bulk

Performs a bulk operation, consisting of 1 or more driver operations. Bulk operations may be nested. For more information and examples, see Bulk Operation in the scripting section.
mdctl-cli
Javascript
Response
1
$> mdctl api POST /accounts/db/bulk --file ./bulk-def.json --env=dev.example
Copied!
1
$.ajax({
2
url: 'https://api.dev.medable.com/example/v2/accounts/bulk',
3
method: 'POST',
4
dataType : 'json',
5
xhrFields: {
6
withCredentials: true
7
},
8
headers: {
9
'Medable-Client-Key': 'GsAqlhnIMzrDeD8V2MBQWq'
10
},
11
data: [{
12
operation: 'updateOne',
13
match: {
14
15
},
16
update: {
17
$set: {
18
c_field: true
19
}
20
},
21
output: false,
22
halt: false
23
}, {
24
operation: 'cursor',
25
where: {
26
27
}
28
}]
29
}).done(function(data) {
30
// ...
31
});
Copied!
1
{
2
"data": [
3
{
4
"_id": "5d44e9d78db1c88b69440f33",
5
"data": {
6
"_id": "5c7fe99ee8355a01008ff899",
7
"object": "account"
8
},
9
"object": "operationResult",
10
"path": "cursor[1][0]",
11
"timestamp": 1564797399479
12
}
13
],
14
"hasMore": false,
15
"object": "list"
16
}
Copied!
Path Params
    object { String } The object name.
Body Params
    ops { Object[] } An array of bulk operations.
      operation { String } The operation name. Can be any one of the driver operations (bulk, readOne, cursor, etc.).
      object { String = undefined } Sets a new object target for the operation.
      name { String = undefined } Wrapped responses will be renamed to this from the operation name.
      halt {Boolean = true } If false, an error will not halt the current bulk operation; Errors will instead be pushed to the output stream.
      output {Boolean = true } If false, results are not pushed to the output stream.
      wrap { Boolean = true } If false, the operationResult wrapper is removed from output documents.
      * { * } Other individual operation options should be added to the operation object (ie. match, where, pipeline, limit, etc.)
Header Params
    Accept { String = application-json } The client can request application/x-ndjson to stream newline-delimited JSON documents.
Response
    { List } A list result.
      data { OperationResult[] } An array of wrapped results.
        _id { ObjectID } The operation result identifier.
        data { * } The wrapped operation result.
        object { String } The object name, operationResult.
        path { String } The operation path in the form operationName[operationIndex][cursorPosition].
        timestamp { Number } The timestamp the operation result ws created, in milliseconds.
      hasMore { Boolean } true when more document exists past the cursor.
      object { String } "list".

POST /:object/db/count

Count object instances.
Path Params
    object { String } The object name.
Body Params
    accessLevel { String|Number } If set, limits the count to those documents where the caller has at least accessLevel.
    limit { Number } If set, limits the maximum count.
    locale { String } Set the locale for the operation. This affect localized string matches.
    maxTimeMS { Number = 10000 } The maximum number of milliseconds the query is allowed to process before an initial cursor is opened.
    skip { Number } Skips skip documents.
    where { Object } A query match filter.
Response
    { Result } A result object.
      data { Number } A document count.
      object { String } result.

POST /:object/db/cursor

Stream a query or aggregation cursor.
Path Params
    object { String } The object name.
Header Params
    Accept { String = application-json } The client can request application/x-ndjson to stream newline-delimited JSON documents.
Body Params
    accessLevel { Number }
    expand { String[] }
    group { Object }
    include { String[] }
    limit { Number }
    locale { String }
    map { String }
    maxTimeMS { Number = 10000 }
    paths { String[] }
    passive { Boolean = false }
    pipeline { Object[] }
    prefix { String } A path to use when retrieving a cursor to a List within a readThrough path.
    skip { Number }
    sort { Object }
    where { Object }
Response
    { List } A list result.
      data { *[] } Array of results.
      hasMore { Boolean } true when more document exists past the cursor.
      object { String } list.

Last modified 29d ago