Skip to main content

Crate apiplant_db

Crate apiplant_db 

Source
Expand description

§apiplant-db

The database layer. It has three jobs:

  • Migrations ([migrate]) — make Postgres match the resource schemas.
  • CRUD (Db) — build parameterised statements for a Resource at runtime and hand rows back as plain JSON.
  • Seeding ([seed]) — load an app’s seed/ directory, the rows it starts life with.

Rows come back as JSON by letting Postgres do the conversion (to_jsonb / jsonb_agg), so the executor only ever extracts a single JSON column and never needs a compile-time entity for a table it only learned about from a TOML file. Values always travel as $n bind parameters; only validated, double-quoted identifiers are ever interpolated.

Re-exports§

pub use migrate::migrate;
pub use seed::seed;
pub use seed::Report as SeedReport;

Modules§

migrate
Runtime migrations.
seed
Seed data: an app’s seed/ directory, loaded into the database.
value
Conversions between JSON (the wire format) and typed SQL values.

Structs§

Db
A connection pool plus the dynamic CRUD executor.
Sort
One ORDER BY key: a column and a direction.

Enums§

Error
Database errors.
Filter
An extra predicate applied to a query: equality (owner/org scoping, ?field= filters) or membership (id IN (…), e.g. “organisations you belong to”). Column names are always validated and quoted; values are always bound.