Skip to content

Commit

Permalink
add DocumentAction UpdateDocument Action
Browse files Browse the repository at this point in the history
  • Loading branch information
jingchen2222 committed Feb 19, 2023
1 parent 79fbdb0 commit 308b90c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/proto/proto/db3_mutation.proto
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ enum DatabaseAction {
AddCollection = 1;
AddDocument = 2;
DeleteDocument = 3;
UpdateDocument = 4;
}

message DatabaseMutation {
Expand Down
10 changes: 7 additions & 3 deletions src/storage/src/db_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,10 @@ impl DbStore {
let (ops, _) = Self::add_document(db, sender, tx, mutation, block_id, mutation_id)?;
Ok(ops)
}
Some(DatabaseAction::UpdateDocument) => {
Self::update_document(db, sender, tx, mutation, block_id, mutation_id)
}

Some(DatabaseAction::DeleteDocument) => Self::delete_document(db, sender, mutation),
None => todo!(),
}
Expand Down Expand Up @@ -885,7 +889,7 @@ mod tests {
collection_mutations: vec![],
document_mutations,
db_address: addr.to_vec(),
action: DatabaseAction::CreateDb.into(),
action: DatabaseAction::DeleteDocument.into(),
};
let json_data = serde_json::to_string(&dm).unwrap();
println!("{json_data}");
Expand All @@ -911,7 +915,7 @@ mod tests {
collection_mutations: vec![],
document_mutations,
db_address: addr.to_vec(),
action: DatabaseAction::CreateDb.into(),
action: DatabaseAction::AddDocument.into(),
};
let json_data = serde_json::to_string(&dm).unwrap();
println!("{json_data}");
Expand All @@ -938,7 +942,7 @@ mod tests {
collection_mutations: vec![],
document_mutations,
db_address: addr.to_vec(),
action: DatabaseAction::CreateDb.into(),
action: DatabaseAction::UpdateDocument.into(),
};
let json_data = serde_json::to_string(&dm).unwrap();
println!("{json_data}");
Expand Down

0 comments on commit 308b90c

Please sign in to comment.