feat: add update to the async API (#1093)

This commit is contained in:
Weston Pace
2024-03-12 14:11:37 -07:00
committed by GitHub
parent 9bc320874a
commit d744972f2f
11 changed files with 315 additions and 75 deletions

View File

@@ -150,6 +150,22 @@ impl Table {
builder.execute().await.default_error()
}
#[napi]
pub async fn update(
&self,
only_if: Option<String>,
columns: Vec<(String, String)>,
) -> napi::Result<()> {
let mut op = self.inner_ref()?.update();
if let Some(only_if) = only_if {
op = op.only_if(only_if);
}
for (column_name, value) in columns {
op = op.column(column_name, value);
}
op.execute().await.default_error()
}
#[napi]
pub fn query(&self) -> napi::Result<Query> {
Ok(Query::new(self.inner_ref()?.query()))