Skip to main content

seed

Function seed 

Source
pub async fn seed(statements: &[&str]) -> Result<(), StorageError>
Expand description

Seed the database by running a batch of raw statements against the active backend, in order, stopping at the first error. Write SQL when using a SeaORM backend, or JSON command documents when using Mongo — the same call works for both, you just author for whichever backend you registered.

// SeaORM / Postgres:
adminx::seed(&[
    "INSERT INTO categories (name, slug) VALUES ('Books','books') ON CONFLICT DO NOTHING",
]).await?;

// Mongo:
adminx::seed(&[
    r#"{"insert":"categories","documents":[{"name":"Books","slug":"books"}]}"#,
]).await?;