Fix UI freezes with large workspaces (#536)

This commit is contained in:
Gregory Schier
2026-08-14 10:15:32 -07:00
committed by GitHub
parent e032c4c8d6
commit d0af512a0c
20 changed files with 491 additions and 108 deletions
@@ -160,6 +160,24 @@ impl<'a> DbContext<'a> {
Ok((m, created))
}
/// Bulk-delete all rows matching a column value with a single statement.
/// Returns the number of rows deleted.
pub fn delete_many<M>(
&self,
col: impl IntoColumnRef,
value: impl Into<SimpleExpr>,
) -> Result<usize>
where
M: UpsertModelInfo,
{
let (sql, params) = Query::delete()
.from_table(M::table_name())
.cond_where(Expr::col(col).eq(value))
.build_rusqlite(SqliteQueryBuilder);
let count = self.conn.execute(sql.as_str(), &*params.as_params())?;
Ok(count)
}
/// Delete a model by its ID. Returns the number of rows deleted.
pub fn delete<M>(&self, m: &M) -> Result<usize>
where
@@ -21,5 +21,9 @@ impl UpdateSource {
#[serde(rename_all = "snake_case", tag = "type")]
pub enum ModelChangeEvent {
Upsert { created: bool },
/// A delete for a workspace implies deletion of every model in that
/// workspace — children are bulk-deleted without their own change rows or
/// events, and consumers must prune the subtree themselves (the frontend
/// model store does this centrally).
Delete,
}