Skip to main content

MongoDb

Struct MongoDb 

Source
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§

Source§

impl MongoDb

Source

pub fn new() -> Self

A MongoDB schema without an executor.

PHP: new MongoDB().

Trait Implementations§

Source§

impl AnalyzeTable for MongoDb

Source§

fn analyze_table(&self, table: &str) -> Result<Statement>

Analyzes table. Read more
Source§

impl Clone for MongoDb

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Comment for MongoDb

Source§

impl Databases for MongoDb

Source§

fn create_database(&self, name: &str) -> Result<Statement>

Creates database name. Read more
Source§

fn drop_database(&self, name: &str) -> Result<Statement>

Drops database name. Read more
Source§

impl Debug for MongoDb

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for MongoDb

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Schema for MongoDb

Source§

fn quote(&self, identifier: &str) -> Result<String>

Identifiers are used as they are.

Source§

fn compile_column_type(&self, column: &Column<Self>) -> Result<String>

The BSON type.

Source§

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>

collMod with the new validator.

Source§

fn compile_truncate(&self, name: &str) -> Result<Statement>

deleteMany with an empty filter.

Source§

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 executor(&self) -> Option<&Executor>

The executor statements carry, if any.
Source§

fn set_executor(&mut self, executor: Executor) -> &mut Self

Sets the executor every statement compiled from now on carries (Statement::execute runs it). Read more
Source§

fn quote_literal(&self, identifier: &str) -> Result<String>

Quotes one identifier, dots included. Read more
Source§

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>

DROP TABLE [IF EXISTS] name. Read more
Source§

fn compile_rename(&self, from: &str, to: &str) -> Result<Statement>

Renames table from to to. Read more
Source§

fn drop_index(&self, table: &str, name: &str) -> Result<Statement>

Drops index name of table. Read more
Source§

fn table(&self, name: impl Into<String>) -> Table<Self>

A blueprint of table name compiled by this schema. Read more
Source§

fn compile_column_definition(&self, column: &Column<Self>) -> Result<String>

The definition of column in CREATE / ALTER TABLE. Read more
Source§

fn compile_generated_clause(&self, column: &Column<Self>) -> String

GENERATED ALWAYS AS (...) STORED|VIRTUAL. Read more
Source§

fn compile_create_suffix(&self, _table: &Table<Self>) -> String

Clauses after the column list of CREATE TABLE (partitioning). Read more
Source§

fn quote_collation(&self, collation: &str) -> Result<String>

A collation name as COLLATE takes it. Read more
Source§

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

The unsigned keyword, or empty where there is none. Read more
Source§

fn compile_index_columns(&self, index: &Index) -> Result<String>

The column list of an index: lengths, collations, operator class, orders and raw expressions. Read more
Source§

impl Serial for MongoDb

Source§

impl Views for MongoDb

Source§

fn create_view( &self, name: &str, query: &mut dyn AnyBuilder, ) -> Result<Statement>

createView over the source collection and pipeline of the builder’s command.

Source§

fn drop_view(&self, name: &str) -> Result<Statement>

Drops view name. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for MongoDb

§

impl !UnwindSafe for MongoDb

§

impl Forget for MongoDb

§

impl Freeze for MongoDb
where *const ArcInner<dyn Fn(&Statement) -> Result<Value<Object>, Error> + Sync + Send> is !null: Freeze, PhantomData<ArcInner<dyn Fn(&Statement) -> Result<Value<Object>, Error> + Sync + Send>>: Freeze,

§

impl Move for MongoDb

§

impl Send for MongoDb
where Arc<dyn Fn(&Statement) -> Result<Value<Object>, Error> + Sync + Send>: Send,

§

impl Sync for MongoDb
where Arc<dyn Fn(&Statement) -> Result<Value<Object>, Error> + Sync + Send>: Sync,

§

impl Unpin for MongoDb
where Arc<dyn Fn(&Statement) -> Result<Value<Object>, Error> + Sync + Send>: Unpin,

§

impl UnsafeUnpin for MongoDb
where *const ArcInner<dyn Fn(&Statement) -> Result<Value<Object>, Error> + Sync + Send> is !null: UnsafeUnpin, PhantomData<ArcInner<dyn Fn(&Statement) -> Result<Value<Object>, Error> + Sync + Send>>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.