[][src]Macro noria::row

macro_rules! row {
    ($tbl:ident, $($k:expr => $v:expr),+ $(,)*) => { ... };
    (@replace_expr ($_t:expr, $sub:expr)) => { ... };
    (@count_tts ($($e:expr),*)) => { ... };
    (@step $tbl:ident, $(@$idx:expr; $ik:expr => $iv:expr,)* $ck:expr => $cv:expr $(, $k:expr => $v:expr)*) => { ... };
    (@step $tbl:ident, $(@$idx:expr; $k:expr => $v:expr),+) => { ... };
}

Create a new row for insertion into a Table using column names.

If the schema of the given table is known, column defaults and NOT NULL restrictions will also be respected. In the future, this method will also check that the provided DataType matches the expected data type for each column.

Values are automatically converted to DataType as necessary.

async fn add_user(users: &mut noria::Table) -> Result<(), noria::error::TableError> {
  let user = noria::row!(users,
    "username" => "jonhoo",
    "password" => "hunter2",
    "created_at" => chrono::Local::now().naive_local(),
    "logins" => 0,
  );
  users.insert(user).await
}