Skip to content

Conversation

@khorshuheng
Copy link
Contributor

Return transaction for workspace database operation, so that the callers can get the encoded update.

@appflowy appflowy merged commit d862b40 into main Dec 5, 2024
6 checks passed
@appflowy appflowy deleted the return-workspace-database-transaction branch December 5, 2024 05:36
.delete_database(&mut self.collab.transact_mut(), database_id);
pub fn delete_database(&mut self, database_id: &str) -> TransactionMut {
let mut txn = self.collab.transact_mut();
self.body.delete_database(&mut txn, database_id);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you can see here, you don't need to return transaction. You can just call self.collab.transact_mut + self.body.delete_database. Because both self.collab and self.body are split in every collab type, creating transaction should never be a problem.

/// use [Self::update_database] to attach more views to the existing database.
///
pub fn add_database(&mut self, database_id: &str, view_ids: Vec<String>) {
pub fn add_database(&mut self, database_id: &str, view_ids: Vec<String>) -> TransactionMut {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to move add_database logic to body and provide transaction from outside. What if you want to call this method, while you already had transaction acquired? This would cause a deadlock.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants