Struct sea_orm::query::Insert[][src]

pub struct Insert<A> where
    A: ActiveModelTrait
{ /* fields omitted */ }

Implementations

Insert one Model or ActiveModel

Model

use sea_orm::{entity::*, query::*, tests_cfg::cake, DbBackend};

assert_eq!(
    Insert::one(cake::Model {
        id: 1,
        name: "Apple Pie".to_owned(),
    })
    .build(DbBackend::Postgres)
    .to_string(),
    r#"INSERT INTO "cake" ("id", "name") VALUES (1, 'Apple Pie')"#,
);

ActiveModel

use sea_orm::{entity::*, query::*, tests_cfg::cake, DbBackend};

assert_eq!(
    Insert::one(cake::ActiveModel {
        id: Unset(None),
        name: Set("Apple Pie".to_owned()),
    })
    .build(DbBackend::Postgres)
    .to_string(),
    r#"INSERT INTO "cake" ("name") VALUES ('Apple Pie')"#,
);

Insert many Model or ActiveModel

use sea_orm::{entity::*, query::*, tests_cfg::cake, DbBackend};

assert_eq!(
    Insert::many(vec![
        cake::Model {
            id: 1,
            name: "Apple Pie".to_owned(),
        },
        cake::Model {
            id: 2,
            name: "Orange Scone".to_owned(),
        }
    ])
    .build(DbBackend::Postgres)
    .to_string(),
    r#"INSERT INTO "cake" ("id", "name") VALUES (1, 'Apple Pie'), (2, 'Orange Scone')"#,
);

Trait Implementations

Formats the value using the given formatter. Read more

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

Get a mutable ref to the query builder

Get an immutable ref to the query builder

Take ownership of the query builder

Build the query as Statement

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.