pub struct MongoDb { /* private fields */ }Expand description
The MongoDB schema: collections with $jsonSchema validators, indexes,
views and databases as JSON commands ({"command": "createCollection", ...}).
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"]}}}"#
);use Utopia\Query\Schema\MongoDB;
$users = (new MongoDB())->table('users');
$users->string('email');
$users->integer('age')->nullable();
echo $users->create()->query, "\n";PHP: Utopia\Query\Schema\MongoDB.
Implementations§
Trait Implementations§
Source§impl AnalyzeTable for MongoDb
impl AnalyzeTable for MongoDb
impl Comment for MongoDb
Source§impl Schema for MongoDb
impl Schema for MongoDb
Source§fn compile_create(
&self,
table: &Table<Self>,
_if_not_exists: bool,
) -> Result<Statement>
fn compile_create( &self, table: &Table<Self>, _if_not_exists: bool, ) -> Result<Statement>
createCollection with a $jsonSchema validator.
Source§fn compile_alter(&self, table: &Table<Self>) -> Result<Statement>
fn compile_alter(&self, table: &Table<Self>) -> Result<Statement>
collMod with the new validator.
Source§fn create_index(
&self,
table: &str,
name: &str,
columns: &[&str],
options: &IndexOptions,
) -> Result<Statement>
fn create_index( &self, table: &str, name: &str, columns: &[&str], options: &IndexOptions, ) -> Result<Statement>
createIndex with 1 / -1 keys (from the orders) and unique.
Source§fn set_executor(&mut self, executor: Executor) -> &mut Self
fn set_executor(&mut self, executor: Executor) -> &mut Self
Sets the executor every statement compiled from now on carries
(
Statement::execute runs it). Read moreSource§fn quote_literal(&self, identifier: &str) -> Result<String>
fn quote_literal(&self, identifier: &str) -> Result<String>
Quotes one identifier, dots included. Read more
Source§fn compile_auto_increment(&self) -> &'static str
fn compile_auto_increment(&self) -> &'static str
The auto-increment keyword. Read more
Source§fn compile_drop(&self, name: &str, _if_exists: bool) -> Result<Statement>
fn compile_drop(&self, name: &str, _if_exists: bool) -> Result<Statement>
DROP TABLE [IF EXISTS] name. Read moreSource§fn table(&self, name: impl Into<String>) -> Table<Self>
fn table(&self, name: impl Into<String>) -> Table<Self>
A blueprint of table
name compiled by this schema. Read moreSource§fn compile_generated_clause(&self, column: &Column<Self>) -> String
fn compile_generated_clause(&self, column: &Column<Self>) -> String
GENERATED ALWAYS AS (...) STORED|VIRTUAL. Read moreSource§fn compile_create_suffix(&self, _table: &Table<Self>) -> String
fn compile_create_suffix(&self, _table: &Table<Self>) -> String
Clauses after the column list of
CREATE TABLE (partitioning). Read moreSource§fn quote_collation(&self, collation: &str) -> Result<String>
fn quote_collation(&self, collation: &str) -> Result<String>
A collation name as
COLLATE takes it. Read moreSource§fn literal(&self) -> StringLiteral
fn literal(&self) -> StringLiteral
How the dialect writes a string literal: comments, defaults and enum
values are inlined, since DDL takes no bound parameters. Read more
Source§fn compile_unsigned(&self) -> &'static str
fn compile_unsigned(&self) -> &'static str
The unsigned keyword, or empty where there is none. Read more
impl Serial for MongoDb
Auto Trait Implementations§
impl !RefUnwindSafe for MongoDb
impl !UnwindSafe for MongoDb
impl Forget for MongoDb
impl Freeze for MongoDb
impl Move for MongoDb
impl Send for MongoDb
impl Sync for MongoDb
impl Unpin for MongoDb
impl UnsafeUnpin for MongoDb
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more