Rust

[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.

Rust
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")?;
Compiles in CI; needs a running service to execute.

Contents

4 submodules, and what the module defines itself.

use utopia_database::adapter::mongo::Mongo;
Rust
pub struct Mongo

The MongoDB adapter. See the module docs.

use utopia_database::adapter::mongo::from_client;
Rust
pub fn from_client(e: utopia_mongo::Error) -> Error

Undocumented.

mongo::casting

Own page

Values to and from what MongoDB stores: dates as UTCDateTime, objects as embedded documents, integers as integers.

mongo::documents

Own page

Documents: reads, creates, updates (operators as aggregation pipelines), upserts, increments, deletes, finds, counts and sums.

mongo::filters

Own page

Queries as MongoDB filters, and the key mappings between documents and stored records.

mongo::schema

Own page

Databases, collections, attributes, relationships and indexes.