Each connection is limited to a single Firestore with MongoDB compatibility database.
A database must be created before connecting to it.
Naming
The following differences apply to naming parts of your data model.
Collections
Collection names matching __.*__ are not supported.
Fields
Field names matching __.*__ are not supported.
Empty field names are not supported.
Documents
The maximum document size is 4 MiB.
The maximum nesting depth of fields is 20. Each Array and Object-typed
field adds one level to the overall depth.
_id
Document _id (top-level field) must be an ObjectId, String, or 64-bit
integer. Other BSON types are not supported.
Empty string ("") and 64-bit 0 (0L) are not supported.
Values
The JavaScript, Symbol, DBPointer, and Undefined BSON types are not
supported.
Date
Date values must fall in [0001-01-01T00:00:00Z, 9999-12-31T23:59:59Z].
Decimal128
NaN, positive infinity, and negative infinity values are
canonicalized on write.
Arithmetic operations on Decimal128 are not supported.
Double
NaN values are canonicalized on write.
Regular expression
Regular expression options must be valid ("i", "m", "s", "u", or "x")
and provided in alphabetical order without repeats.
Queries
Natural sort order (queries without an explicit sort) does not match
insertion order or order by _id ascending.
Aggregations
Aggregations are limited to 250 stages.
The $merge and $out stages are not supported. See the
commands section for a complete list of supported stages and operators.
The $lookup stage is limited to specifying a foreignField on _id.
Writes
Documents with names beginning with a dollar sign ("$") cannot be
created using the upsert feature of update or findAndModify.
Make sure your connection string
includes retryWrites=false (or use the method appropriate to your driver)
to make sure the driver does not attempt to use this feature.
Retryable writes are not supported.
Transactions
Snapshot isolation and serializable transactions are
supported.
By default, transactions use optimistic concurrency controls
with snapshot isolation.
Read concern
Firestore with MongoDB compatibility supports the snapshot , majority, and linearizable
read concerns. The default is snapshot which refers to snapshot isolation.
Use linearizable when the application requires strict consistency
and must prevent write skew anomalies. For other workloads,
snapshot can improve performance and reduce transaction contention.
Write concern
Only w: 'majority' and w: 1 write concerns are supported.
Read preference
Only the primary, primaryPreferred, primary_preferred,
secondary_preferred, and nearest read concerns are supported.
Indexes
Wildcard indexes are not supported.
Firestore with MongoDB compatibility does not automatically create an
index on _id, but it ensures values of _id are unique within a
collection.
Indexes without multi-key enabled are not automatically changed to
multi-key indexes
based on write operations. You must enable multi-key when you
create the index and the option cannot be changed.
Errors
Error codes and messages may differ between Firestore with MongoDB compatibility and
MongoDB.
Commands
The following behavior differences apply to specific commands.
Commands not listed in the following tables are unsupported.
maxTimeMS is accepted by most commands but may be ignored.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-28 UTC."],[],[],null,["# Behavior differences\n====================\n\nThis page describes behavioral differences between Firestore with MongoDB compatibility and MongoDB.\n\nFor a breakdown of supported features depending on MongoDB version, see:\n\n- [Supported features: 8.0](/firestore/mongodb-compatibility/docs/supported-features-80)\n- [Supported features: 7.0](/firestore/mongodb-compatibility/docs/supported-features-70)\n- [Supported features: 6.0](/firestore/mongodb-compatibility/docs/supported-features-60)\n- [Supported features: 5.0](/firestore/mongodb-compatibility/docs/supported-features-50)\n\nConnections and databases\n-------------------------\n\n- Each connection is limited to a single Firestore with MongoDB compatibility database.\n- A database must be created before connecting to it.\n\nNaming\n------\n\nThe following differences apply to naming parts of your data model.\n\n### Collections\n\n- Collection names matching `__.*__` are not supported.\n\n### Fields\n\n- Field names matching `__.*__` are not supported.\n- Empty field names are not supported.\n\nDocuments\n---------\n\n- The maximum document size is 4 MiB.\n- The maximum nesting depth of fields is 20. Each Array and Object-typed field adds one level to the overall depth.\n\n### `_id`\n\n- Document `_id` (top-level field) must be an ObjectId, String, or 64-bit integer. Other BSON types are not supported.\n- Empty string (\"\") and 64-bit 0 (0L) are not supported.\n\nValues\n------\n\n- The JavaScript, Symbol, DBPointer, and Undefined BSON types are not supported.\n\n### Date\n\n- Date values must fall in `[0001-01-01T00:00:00Z, 9999-12-31T23:59:59Z]`.\n\n### Decimal128\n\n- `NaN`, positive infinity, and negative infinity values are canonicalized on write.\n- Arithmetic operations on Decimal128 are not supported.\n\n### Double\n\n- `NaN` values are canonicalized on write.\n\n### Regular expression\n\n- Regular expression options must be valid (\"i\", \"m\", \"s\", \"u\", or \"x\") and provided in alphabetical order without repeats.\n\nQueries\n-------\n\n- Natural sort order (queries without an explicit sort) does not match insertion order or order by `_id` ascending.\n\nAggregations\n------------\n\n- Aggregations are limited to 250 stages.\n- The `$merge` and `$out` stages are not supported. See the [commands](#commands) section for a complete list of supported stages and operators.\n- The `$lookup` stage is limited to specifying a `foreignField` on `_id`.\n\nWrites\n------\n\n- Documents with names beginning with a dollar sign (\"$\") cannot be created using the upsert feature of `update` or `findAndModify`.\n- Make sure your connection string includes `retryWrites=false` (or use the method appropriate to your driver) to make sure the driver does not attempt to use this feature. Retryable writes are not supported.\n\nTransactions\n------------\n\n- Snapshot isolation and serializable transactions are\n supported.\n\n- By default, transactions use optimistic concurrency controls\n with snapshot isolation.\n\nRead concern\n------------\n\n- Firestore with MongoDB compatibility supports the `snapshot` , `majority`, and `linearizable`\n read concerns. The default is `snapshot` which refers to snapshot isolation.\n\n Use `linearizable` when the application requires strict consistency\n and must prevent write skew anomalies. For other workloads,\n `snapshot` can improve performance and reduce transaction contention.\n\nWrite concern\n-------------\n\n- Only `w: 'majority'` and `w: 1` write concerns are supported.\n\nRead preference\n---------------\n\n- Only the `primary`, `primaryPreferred`, `primary_preferred`, `secondary_preferred`, and `nearest` read concerns are supported.\n\nIndexes\n-------\n\n- Wildcard indexes are not supported.\n- Firestore with MongoDB compatibility does not automatically create an index on `_id`, but it ensures values of `_id` are unique within a collection.\n- Indexes without multi-key enabled are not automatically changed to [multi-key indexes](/firestore/mongodb-compatibility/docs/index-overview#multi-key_indexes_for_array_values) based on write operations. You must enable multi-key when you create the index and the option cannot be changed.\n\nErrors\n------\n\n- Error codes and messages may differ between Firestore with MongoDB compatibility and MongoDB.\n\nCommands\n--------\n\nThe following behavior differences apply to specific commands.\n\n- Commands not listed in the following tables are unsupported.\n- `maxTimeMS` is accepted by most commands but may be ignored.\n\n### Queries and writes\n\n### Transactions and sessions\n\n### Administration\n\nWhat's next\n-----------\n\n- Run the [Quickstart: Create a database and connect to it](/firestore/mongodb-compatibility/docs/create-and-query-database).\n- For a full list of supported features, see [Supported MongoDB data types, drivers, and features](/firestore/mongodb-compatibility/docs/supported-data-types-drivers)."]]