Setiap koneksi dibatasi untuk satu database Firestore dengan kompatibilitas MongoDB.
Database harus dibuat sebelum terhubung ke database tersebut.
Penamaan
Perbedaan berikut berlaku untuk penamaan bagian model data Anda.
Koleksi
Nama koleksi yang cocok dengan __.*__ tidak didukung.
Kolom
Nama kolom yang cocok dengan __.*__ tidak didukung.
Nama kolom kosong tidak didukung.
Dokumen
Ukuran dokumen maksimum adalah 4 MiB.
Kedalaman bertingkat maksimum kolom adalah 20. Setiap kolom berjenis Array dan Objek
menambahkan satu tingkat ke kedalaman keseluruhan.
_id
Dokumen _id (kolom tingkat teratas) harus berupa ObjectId, String, atau bilangan bulat 64-bit. Jenis BSON lainnya tidak didukung.
String kosong ("") dan 0 64-bit (0L) tidak didukung.
Nilai
Jenis BSON JavaScript, Symbol, DBPointer, dan Undefined tidak didukung.
Tanggal
Nilai tanggal harus berada dalam rentang [0001-01-01T00:00:00Z, 9999-12-31T23:59:59Z].
Decimal128
Nilai NaN, tak terhingga positif, dan tak terhingga negatif
dikanonisasi saat penulisan.
Operasi aritmatika pada Decimal128 tidak didukung.
Ganda
Nilai NaN dikanonisasi saat penulisan.
Ekspresi reguler
Opsi ekspresi reguler harus valid ("i", "m", "s", "u", atau "x")
dan diberikan dalam urutan abjad tanpa pengulangan.
Kueri
Urutan pengurutan alami (kueri tanpa pengurutan eksplisit) tidak cocok dengan urutan penyisipan atau urutan berdasarkan _id menaik.
Agregasi
Agregasi dibatasi hingga 250 tahap.
Tahap $merge dan $out tidak didukung. Lihat bagian
perintah untuk mengetahui daftar lengkap operator dan tahap yang didukung.
Tulis
Dokumen dengan nama yang diawali dengan tanda dolar ("$") tidak dapat
dibuat menggunakan fitur upsert update atau findAndModify.
Pastikan string koneksi Anda
mencakup retryWrites=false (atau gunakan metode yang sesuai untuk driver Anda)
untuk memastikan driver tidak mencoba menggunakan fitur ini.
Penulisan yang dapat dicoba lagi tidak didukung.
Transaksi
Transaksi snapshot tidak didukung.
Transaksi menggunakan kontrol serentak pesimis dengan penguncian. Untuk menghindari
persaingan kunci, batasi jumlah data yang dibaca dalam transaksi.
Indeks
Indeks karakter pengganti tidak didukung.
Indeks unik tidak didukung
Firestore dengan kompatibilitas MongoDB tidak otomatis membuat indeks pada _id, tetapi memastikan nilai _id unik dalam koleksi.
Indeks tanpa mengaktifkan multi-kunci tidak otomatis diubah menjadi
indeks multi-kunci
berdasarkan operasi tulis. Anda harus mengaktifkan multi-kunci saat
membuat indeks dan opsi ini tidak dapat diubah.
Baca masalah
Hanya tingkat perhatian baca majority yang didukung.
Menulis kekhawatiran
Hanya masalah penulisan w: 'majority' dan w: 1 yang didukung.
Membaca preferensi
Hanya masalah pembacaan primary, primaryPreferred, primary_preferred,
secondary_preferred, dan nearest yang didukung.
Error
Kode dan pesan error mungkin berbeda antara Firestore dengan kompatibilitas MongoDB dan MongoDB.
Perintah
Perbedaan perilaku berikut berlaku untuk perintah tertentu.
Perintah yang tidak tercantum dalam tabel berikut tidak didukung.
maxTimeMS diterima oleh sebagian besar perintah, tetapi mungkin diabaikan.
Kueri dan penulisan
Perintah
Kolom yang Tidak Didukung
find
comment
readConcern
max
min
returnKey
showRecordId
tailable
oplogReplay
noCursorTimeout
awaitData
allowPartialResults
collation
allowDiskUsage
let
aggregate
bypassDocumentValidation
readConcern
collation
hint
comment
let
insert
bypassDocumentValidation
comment
update
collation
arrayFilters
hint
delete
comment
write
Dalam pernyataan penghapusan:
collation
hint
findAndModify
fields
bypassDocumentValidation
collation
arrayFilters
hint
comment
let
count
hint
readConcern
collation
comment
distinct
readConcern
collation
comment
hint
getMore
comment
killCursors
(tidak ada)
Transaksi dan sesi
Perintah
Kolom yang Tidak Didukung
commitTransaction
comment
abortTransaction
comment
endSessions
(tidak ada)
Administrasi
Perintah
Kolom yang Tidak Didukung
Catatan
listDatabases
authorizedDatabases
comment
filter harus kosong jika diberikan.
listCollections
comment
authorizedCollections harus salah jika diberikan.
listIndexes
comment
createCollection
timeseries
expireAfterSeconds
clusteredIndex
changeStreamPreAndPostImages
size
max
storageEngine
validator
validationLevel
validationAction
indexOptionDefaults
viewOn
pipeline
collation
writeConcern
encryptedFields
comment
Perintah ini adalah no-op.
capped harus bernilai salah (false) jika diberikan.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-08-18 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)."]]