LogoLogo
  • Introduction
  • Features
  • Getting Started
    • Cortex User Guide
      • Organizations
      • Log in
      • Generate an API key
      • Make your first API request
      • Configure the org settings
      • Set up a data model
        • Create custom objects
        • Add custom properties
      • One-to-many relationships
      • Read and write data
      • Making a Request
      • Handling responses
      • Authentication
      • Two-factor authentication
      • Set third-party cookies
      • Connections
      • Upload files
      • Cortex iOS
      • Get started with Swift
      • Cortex service accounts
      • Cortex developer tools
      • Automated Account Notifications
  • Cortex API
    • Overview
    • Objects
      • Objects Overview
      • Organization
      • Account
      • Connections
      • Notifications
      • Stats
      • Logs
      • Export
      • Events
      • Room
    • Object Definition
      • Object Properties
        • Any
        • Binary
        • Boolean
        • Date
        • Document
        • File
        • Geometry
        • List
        • Number
        • ObjectId
        • Reference
        • String
    • Object Types
    • Access Control
    • Querying
      • Query Operators
      • Property Selection
      • Property Access
    • Aggregating
      • Aggregation Operators
    • Scripting
      • Script Types
      • Script Limits
      • ObjectId
      • CortexObject
        • Accounts
        • Views
      • Cursors
      • Operations
      • Script Modules
        • API Module
        • Base64 Module
        • Cache Module
        • Connections Module
        • Console Module
        • Consts Module
        • Counters Module
        • Crypto Module
        • HTTP Module
        • Logger Module
        • Notifications Module
        • Request Module
        • Response Module
        • SAML Module
        • Schemas Modules
        • Script Module
        • Session Module
        • Util.id Module
        • Util.ip Module
        • Util.paths Module
        • XML Module
        • Developer
        • Config
        • Renderer
        • SFTP
        • FTP
        • DB
          • Cursors
          • Driver
      • Static Methods
        • Accounts
        • Views
        • Cursors
      • Audit
      • Environments
      • HTTP Driver
      • Notifications
        • Firebase Cloud Messaging (FCM)
        • Tencent Push Notification Service Configuration
      • Televisit
      • Transforms
      • Localization
      • Available Javascript Libraries
    • Decorators
      • Runtime
        • Acl
        • As
        • Log
        • Profile
      • Static
        • Env
        • Job
        • Object
        • On
        • Policy
        • Route
        • Transform
        • Trigger
    • Expressions
      • Primer
      • Pipelines
      • Operators
      • Accumulators
      • Variables
      • Conditionals
      • Transforms
      • Triggers
      • On
      • Events
    • Faults
      • Fault Reference
  • Releases
    • Cortex Release Notes
      • Cortex API 2.28.3 (R3.4.6)
      • Cortex API 2.28.1 (R3.4.3)
      • Cortex API 2.27.2 (R3.4.1)
      • Cortex API 2.27.1 (R3.3.5)
      • SQL DB Connector 1.3.4 (R3.3.3)
      • Cortex API 2.26.2 (R3.3.1)
      • Cortex API 2.26.1 (R3.2.2)
      • Cortex API 2.26.0 (R3.2.1)
      • SQL DB Connector 1.3.3
      • Cortex API 2.25.0 (R3.1.1)
      • SQL DB Connector 1.3.2 (R3.1.0)
      • Cortex API 2.24.2 (R3.0.2)
      • SQL DB Connector 1.3.1 (R3.0.0)
      • Cortex API 2.24.1 (R2.3.3)
      • Cortex API 2.24.0 (R2.3.2)
      • SQL DB Connector 1.3.0 (R2.3.0)
      • Cortex API 2.23.0 (R2.2.4)
      • SQL DB Connector 1.2.0 (R2.2.0)
      • Cortex API 2.22.2 (R2.1.2)
      • Cortex API 2.22.1 and SQL DB Connector 1.1.1 (R2.0.1)
      • Cortex API 2.22.0
      • Cortex API 2.21.3
      • Cortex API 2.21.2
      • Cortex Web 4.16.0
      • Cortex Web 4.15.1
      • Cortex API 2.20.1
      • Cortex Web 4.14.0
      • Cortex Renderer 1.3.3
      • Cortex API 2.19.4
      • Cortex API 2.19.3 and Cortex Web 4.13.1
      • Cortex Renderer 1.3.2
      • Cortex API 2.19.1
      • Cortex API 2.18.0
      • Cortex API 2.17.6
      • Cortex API 2.17.5
      • Cortex API 2.17.4
      • Cortex API 2.17.3
      • Cortex API 2.17.2
      • Cortex API 2.17.1
      • Cortex API 2.16.0
      • Cortex API 2.15.9
      • Cortex API 2.15.8-1
      • Cortex 2.15.8
      • Cortex API 2.18.1
      • Cortex API 2.16.1
      • Cortex Renderer 1.3.1
      • Cortex Renderer 1.3.0
      • Cortex Renderer 1.2.2
      • Cortex Renderer 1.2.1
      • Cortex Renderer 1.2.0
    • Third-Party License Attribution

© 2025 Medable, Inc. All rights reserved.

On this page
  • POST /:object/db/bulk
  • POST /:object/db/count
  • POST /:object/db/cursor

Was this helpful?

  1. Cortex API
  2. Scripting

HTTP Driver

Last updated 3 years ago

Was this helpful?

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 in the scripting section.

$> 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: {
      email: 'me@example.com'
    },
    update: {
      $set: {
        c_field: true
      } 
    },
    output: false,
    halt: false
  }, {
    operation: 'cursor',
    where: {
      email: 'me@example.com'
    }         
  }]
}).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.

Bulk Operation