Welcome to the MongoDB Query Language (MQL) section of the Polypheny documentation! This section is dedicated to providing comprehensive information about utilizing MongoDB’s powerful query language within the Polypheny platform.
What is MongoDB Query Language?
MongoDB Query Language (MQL) is the rich and expressive query language used by MongoDB, a popular NoSQL database. MQL offers a potent suite of features that allow you to work with your data in versatile and powerful ways. The language is document-oriented, meaning that it operates on BSON (Binary JSON) document data structures.
Data is represented as collections of JSON-like documents. This data representation is inherently flexible, accommodating complex nested data structures with ease.
Here’s an example of a simple query:
db.collection.find({ "name" : "John Doe" })
In the MongoDB Query Language, db
is a reference to the current database. In Polypheny, this referes to a namespace. The db
variable is used at the beginning of every query to specify which namespace you are working with.
The current namespace is the namespace that the user has selected to work with, and all subsequent operations that use the db
variable are performed within the context of that namespace.
In the example above, collection
refers to the collection within that namespace, find
is the operation being performed, and { "name" : "John Doe" }
is the query criteria.
How to Select the Namespace
To select the namespace, you use the use
command followed by the name of the namespace.
Here’s an example:
use customers
In this case, customers
would be the name of the namespace you want to select. Once this command is executed, the db
variable now points to customers
, and any subsequent operations that you perform using db
will be on customers
.
When to Use MongoDB Query Language
MongoDB’s query language has comprehensive capabilities that allow for complex nested queries, text search, geospatial queries, multi-document ACID transactions, and more.
In the context of Polypheny, the MongoDB Query Language is one of the supported query languages and can be used interchangeably with others depending on your use case. Whether you’re dealing with vast amounts of data, need the flexibility of a document-oriented model, or require complex querying capabilities, MQL is a valuable tool within the Polypheny ecosystem.