Navigation

CRUD & Aggregation APIs

You can access most of the CRUD and Aggregation functionality of MongoDB version 3.6 with the MongoDB service; however, MongoDB Realm does not support all operations available in standard tools and clients. This page lists specific MongoDB operations that are not available when you connect to MongoDB Atlas through MongoDB Realm. For a high-level overview of MongoDB feature availability in MongoDB Realm, see Service Limitations.

Info With Circle IconCreated with Sketch.Note

The following tables track operation support with the labels "User Function" and "System Function". A "User Function" is a Function run using an application user's user context only. This is the default behavior for all Functions, and in this kind of Function all rules, roles, and permissions apply to the active user. A "System Function" is a Function run without regard for rules, roles, and permissions. You can learn more about how to run a Functions as a system user in the Functions overview.

MongoDB Realm 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.

OperationUser FunctionSystem Function
$eqYesYes
$gtYesYes
$gteYesYes
$inYesYes
$ltYesYes
$lteYesYes
$neYesYes
$ninYesYes
OperationUser FunctionSystem Function
$andYesYes
$notYesYes
$norYesYes
$orYesYes
OperationUser FunctionSystem Function
$allYesYes
$elemMatchYesYes
$sizeYesYes
OperationUser FunctionSystem Function
$existsYesYes
$typeYesYes
OperationUser FunctionSystem Function
$modYesYes
$exprNoYes
$jsonSchemaNoYes
$regexNoYes
$textNoYes
$whereNoYes
OperationUser FunctionSystem Function
$geoIntersectsNoYes
$geoWithinNoYes
$nearNoYes
$nearSphereNoYes
OperationUser FunctionSystem Function
$bitsAllClearNoYes
$bitAllSetNoYes
$bitsAnyClearNoYes
$bitsAnySetNoYes

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

OperationUser FunctionSystem Function
$currentDateYesYes
$incYesYes
$minYesYes
$maxYesYes
$mulYesYes
$renameYesYes
$setYesYes
$setOnInsertYesYes
$unsetYesYes
OperationUser FunctionSystem Function
$ (Positional Update)YesYes
$addToSetYesYes
$popYesYes
$pullYesYes
$pushYesYes
$pullAllYesYes
$[] (All Positional Update)NoYes
$[element] (Filtered Positional Update)NoYes
ModifierUser FunctionSystem Function
$eachYesYes
$positionYesYes
$sliceYesYes
$sortYesYes
OperatorUser FunctionSystem Function
$bitYesYes

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

Info With Circle IconCreated with Sketch.Note
MongoDB Realm does not support the collection.bulkWrite() method.

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

Realm supports the following OrderedBulkOperation methods:

OperationUser FunctionSystem Function
execute.YesYes
find.YesYes
insert.YesYes

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

Realm supports the following UnorderedBulkOperation methods:

OperationUser FunctionSystem Function
execute.YesYes
find.YesYes
insert.YesYes

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

OptionUser ContextSystem Context
Read Isolation (Read Concern)NoYes
Write Acknowledgment (Write Concern)NoYes
CollationNoYes

MongoDB Realm supports aggregation on the both the database and collection level using the following commands:

MongoDB Realm 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.

StageUser ContextSystem Context
$collStatsNoYes
$currentOpNoYes
$facetNoYes
$geoNearNoYes
$graphLookupNoYes
$indexStatsNoNo
$lookupYesYes
$mergeNoYes
$outNoYes

$search

Important With Circle IconCreated with Sketch.Important

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

YesYes
$textNoYes
$unionWithYesYes
Info With Circle IconCreated with Sketch.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.

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

OperatorUser ContextSystem Context
$functionNoYes

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

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

Info With Circle IconCreated with Sketch.Note

Realm apps cannot run commands on the admin database.

CommandUnsupported OptionsRealm-Specific Options
find
  • hint
  • skip
  • batchSize
  • comment
  • maxScan
  • maxTimeMS
  • readConcern
  • max
  • min
  • returnKey
  • showRecordId
  • tailable
  • awaitData
  • oplogReplay
  • noCursorTimeout
  • allowPartialResults
  • collation
aggregate
  • explain
  • allowDiskUse
  • maxTimeMS
  • readConcern
  • collation
  • bypassDocumentValidation
  • hint
  • comment
  • writeConcern
  • enforceReadPref
count
  • limit
  • skip
  • hint
  • readConcern
insert
  • writeConcern
  • bypassDocumentValidation
update
  • bypassDocumentValidation
  • collation
  • arrayFilters
delete
  • collation
Give Feedback