Docs Menu

Docs HomeAtlas App Services

CRUD & Aggregation APIs

On this page

  • Overview
  • CRUD Operations
  • Query Operators
  • Update Operators
  • Bulk Write Operations
  • Query Options
  • Aggregation
  • Aggregation Methods
  • Aggregation Pipeline Stage Availability
  • Aggregation Pipeline Operator Availability
  • Database Commands
  • Database Command Availability

This page lists MongoDB data source support for MongoDB commands, operators, options, and aggregation stages.

For information on how to read and write data in MongoDB from a function, see Query MongoDB Atlas.

For more information on supported features and limitations, see Service Limitations.

Note

Support for an operation may depend on whether you're running the operation as an application user or as a system user.

  • A user function runs in the context of a specific application user and enforces data access permissions and schema validation, which makes some operations untenable.

  • A system function runs as a generic system user and is not subject to rules or schema validation. Some operations are only available in system functions.

Atlas App Services supports most query operators for queries that run in a user function. However, some evaluation operators and all geospatial and bitwise operators are only available in system functions.

Operation
User Function
System Function
$eq
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Operation
User Function
System Function
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Operation
User Function
System Function
Yes
Yes
Yes
Yes
Yes
Yes
Operation
User Function
System Function
Yes
Yes
Yes
Yes
Operation
User Function
System Function
Yes
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
Operation
User Function
System Function
No
Yes
No
Yes
No
Yes
No
Yes
Operation
User Function
System Function
No
Yes
No
Yes
No
Yes
No
Yes

App Services supports most update operators for queries that run in a user function. However, some array update operators are only available in system functions.

Operation
User Function
System Function
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Operation
User Function
System Function
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Modifier
User Function
System Function
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Operator
User Function
System Function
Yes
Yes

App Services supports bulk write operations using the same API as the MongoDB Node.js driver.

You define ordered bulk operations by calling collection.initializeOrderedBulkOp() and manipulating the OrderedBulkOperation object that it returns.

App Services supports the following OrderedBulkOperation methods:

Operation
User Function
System Function
Yes
Yes
Yes
Yes
Yes
Yes

You define unordered bulk operations by calling collection.initializeUnorderedBulkOp() and manipulating the OrderedBulkOperation object that it returns.

App Services supports the following UnorderedBulkOperation methods:

Operation
User Function
System Function
Yes
Yes
Yes
Yes
Yes
Yes

App Services does not support configuring the following options for any CRUD operation in user functions. All query options are available in system functions.

App Services supports aggregation on the both the database and collection level using the following commands:

App Services does not support the following aggregation pipeline stages when you run an aggregation pipeline in the context of an application user. All aggregation pipeline stages are available to the system user except for $indexStats.

Stage
User Context
System Context
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
No
Yes
Yes
No
Yes
No
Yes

$search

Important

App Services performs $search operations as a system user and enforces field-level rules on the returned search results. This means that a user may search on a field for which they do not have read access. In this case, the search is based on the specified field but no returned documents include the field.

Note

$$SEARCH_META Variable Availability

The $$SEARCH_META aggregation variable is only available for functions that run as system or if the first role on the searched collection has its apply_when and read expressions set to true.

If neither of these two scenarios apply, $$SEARCH_META is undefined and the aggregation will fail.

Yes
Yes
Yes
Yes

Note

By default, $merge and $out route the entire aggregation operation to the cluster's primary node. If you want to force these stages to respect your configured cluster read preference, set the enforceReadPref option to true.

App Services supports all aggregation pipeline operators when you run an aggregation pipeline in the system user context. App Services supports all pipeline operators in an application user context with the following exceptions:

Operator
User Context
System Context
No
Yes

App Services does not support any database commands in the Client SDKs or Functions. You can, however, call a limited subset of database commands when connected to a MongoDB cluster over the App Services wire protocol.

The following database commands are partially supported over the wire protocol. Unsupported options for each command are listed below.

Note

App Services Apps cannot run commands on the admin database.

Command
Unsupported Options
App Services-Specific Options
  • hint

  • skip

  • batchSize

  • comment

  • maxScan

  • maxTimeMS

  • readConcern

  • max

  • min

  • returnKey

  • showRecordId

  • tailable

  • awaitData

  • oplogReplay

  • noCursorTimeout

  • allowPartialResults

  • collation

  • explain

  • allowDiskUse [1]

  • readConcern

  • collation

  • bypassDocumentValidation

  • hint

  • comment

  • writeConcern

  • enforceReadPref

  • limit

  • skip

  • hint

  • readConcern

  • writeConcern

  • bypassDocumentValidation

  • bypassDocumentValidation

  • collation

  • collation

[1] App Services supports allowDiskUse when run in a Function or Trigger with system-level permissions.
←  Connect to MongoDB Data SourcesQuery Atlas from Client Apps →