MongoDB to SurrealDB mapping
Quickly learn how to map your MongoDB knowledge to corresponding SurrealDB concepts and syntax.
Introduction
As a multi-model database, SurrealDB offers a lot of flexibility. Our SQL-like query language SurrealQL is a good example of this, where we often have more than one way to achieve the same result, depending on developer preference. In this mapping guide, we will focus on the syntax that most closely resembles the MongoDB query language (MQL).
Concepts mapping
For more in-depth explanations of SurrealDB concepts, see the concepts page.
MongoDB | SurrealDB |
---|---|
database | database |
collection | table |
document | record |
field | field |
index | index |
ObjectId | record id |
transactions | transactions |
reference and embedding | record links, embedding and graph relations |
Syntax mapping
Let's get you up to speed with SurrealQL syntax with some CRUD examples.
Create
As MongoDB is schemaless, only the SurrealQL schemaless approach is shown below. For a schemafull option see the define table page.
For more SurrealQL examples, see the create and insert pages.
MQL | SurrealQL |
---|---|
|
|
Collection implicitly created if it doesn't exist |
Table implicitly created if it doesn't exist |
|
|
|
|
Read
For more SurrealQL examples, see the select, live select and return pages.
MQL | SurrealQL |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Update
For more SurrealQL examples, see the update page.
MQL | SurrealQL |
---|---|
|
|
|
|
Delete
For more SurrealQL examples, see the delete and remove pages.
MQL | SurrealQL |
---|---|
|
|
|
|
|
|