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
$> mdctl api POST /accounts/db/bulk --file ./bulk-def.json --env=dev.example
$.ajax({
url: 'https://api.dev.medable.com/example/v2/accounts/bulk',
method: 'POST',
dataType : 'json',
xhrFields: {
withCredentials: true
},
headers: {
'Medable-Client-Key': 'GsAqlhnIMzrDeD8V2MBQWq'
},
data: [{
operation: 'updateOne',
match: {
},
update: {
$set: {
c_field: true
}
},
output: false,
halt: false
}, {
operation: 'cursor',
where: {
}
}]
}).done(function(data) {
// ...
});
{
"data": [
{
"_id": "5d44e9d78db1c88b69440f33",
"data": {
"_id": "5c7fe99ee8355a01008ff899",
"object": "account"
},
"object": "operationResult",
"path": "cursor[1][0]",
"timestamp": 1564797399479
}
],
"hasMore": false,
"object": "list"
}
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.

Copy link
On this page
POST /:object/db/bulk
POST /:object/db/count
POST /:object/db/cursor