mongodb
Module[MongoDb]: the MongoDB schema, whose statements are JSON commands.
Contents
use utopia_query::schema::mongodb::MongoDb;Rust
pub struct MongoDbThe MongoDB schema: collections with $jsonSchema validators, indexes,
views and databases as JSON commands ({"command": "createCollection", ...}).
Rust
use utopia_query::schema::{MongoDb, Schema};
let mut users = MongoDb::new().table("users");
users.string("email", 255);
users.integer("age").nullable();
assert_eq!(
users.create()?.query,
r#"{"command":"createCollection","collection":"users","validator":{"$jsonSchema":{"bsonType":"object","properties":{"email":{"bsonType":"string"},"age":{"bsonType":"int"}},"required":["email"]}}}"#
);Also implements
Debug.