mongo
Module[Mongo]: the MongoDB adapter.
A collection is a MongoDB collection named <namespace>_<id> in the
adapter's database; a document is a BSON document whose internal
attributes are stored under _uid ($id), _id ($sequence, a UUIDv7
string), _tenant, _createdAt, _updatedAt and _permissions.
Attributes need no schema: creating one is a no-op, and in schemaless
mode (Adapter::set_support_for_attributes false) documents carry
any attribute. Filters, sorts, cursors and permissions become a find
filter; operators an aggregation pipeline update; transactions are the
driver's, on a replica set.
use std::sync::Arc;
use utopia_database::Adapter;
use utopia_database::adapter::mongo::Mongo;
use utopia_mongo::{Client, Config};
let client = Client::new(Config::new("appwrite", "localhost", 27017, "root", "password"))
.map_err(utopia_database::adapter::mongo::from_client)?;
let adapter = Mongo::new(Arc::new(client)).await?;
adapter.set_database("appwrite")?;
adapter.set_namespace("_1")?;Contents
4 submodules, and what the module defines itself.
use utopia_database::adapter::mongo::Mongo;pub struct MongoThe MongoDB adapter. See the module docs.
use utopia_database::adapter::mongo::from_client;pub fn from_client(e: utopia_mongo::Error) -> ErrorUndocumented.
mongo::casting
Own pageValues to and from what MongoDB stores: dates as UTCDateTime,
objects as embedded documents, integers as integers.
mongo::documents
Own pageDocuments: reads, creates, updates (operators as aggregation pipelines), upserts, increments, deletes, finds, counts and sums.
mongo::filters
Own pageQueries as MongoDB filters, and the key mappings between documents and stored records.
mongo::schema
Own pageDatabases, collections, attributes, relationships and indexes.