[−][src]Trait actyxos_data_flow::db::DbRecord
representation of a database table for some record type
Required methods
fn table_version() -> i32
version number for the format
It is good practice to start with 1 and increment whenver the contents of the table should be recomputed (e.g. a logic change or a change to the column definitions).
fn table_name() -> &'static str
name of the table
If the database has been configured to use a common table_prefix()
then that is prepended to this name to obtain the final name used in the database.
fn table_name() -> &'static str { "my_table" }
fn columns() -> &'static [DbColumn]
columns of this table
Note that this intentionally has a return type that cannot be implemented dynamically.
fn columns() -> &'static [DbColumn] { static X: &[DbColumn] = &[ DbColumn { name: "x", tpe: "bigint not null", exclude: false, index: true } ]; X }
fn values(&self) -> Vec<D::SqlValue>
values to fill the non-exluded columns as defined by the columns
function
use actyxos_data_flow::db::{DbColumn, DbMechanics, DbRecord, SqliteDbMechanics}; struct X { x: i64 } impl DbRecord<SqliteDbMechanics> for X { fn table_version() -> i32 { 1 } fn table_name() -> &'static str { "my_table" } fn columns() -> &'static [DbColumn] { static X: &[DbColumn] = &[ DbColumn { name: "x", tpe: "bigint not null", exclude: false, index: true } ]; X } fn values(&self) -> Vec<<SqliteDbMechanics as DbMechanics>::SqlValue> { vec![Box::new(self.x)] } }
It is important to ensure that the values returned are fully consistent with all non-excluded
column descriptions returned by the columns
method, they must appear in
the same order.
Implementations on Foreign Types
impl<D: DbMechanics> DbRecord<D> for ()
[src]
needed for the Union default type parameters — unused tables don’t have names and contain nothing