MCPcopy Create free account
hub / github.com/AppFlowy-IO/AppFlowy-Collab / upsert

Method upsert

collab/src/util.rs:349–366  ·  view source on GitHub ↗
(&self, txn: &mut TransactionMut, id: &str)

Source from the content-addressed store, hash-verified

347 }
348
349 fn upsert<V>(&self, txn: &mut TransactionMut, id: &str) -> V
350 where
351 V: DefaultPrelim + TryFrom<Out>,
352 {
353 match self.index_by_id(txn, id) {
354 None => self.push_back(txn, V::default_prelim()),
355 Some(i) => {
356 let out = self.get(txn, i).unwrap();
357 match V::try_from(out) {
358 Ok(shared_ref) => shared_ref,
359 Err(_) => {
360 self.remove(txn, i);
361 self.push_back(txn, V::default_prelim())
362 },
363 }
364 },
365 }
366 }
367}
368
369impl<T> ArrayExt for T where T: Array {}

Callers 6

update_mapMethod · 0.80
insert_group_settingMethod · 0.80
insert_sortMethod · 0.80
update_calculationMethod · 0.80
update_filterMethod · 0.80
insert_filterMethod · 0.80

Implementers 1

util.rscollab/src/util.rs

Calls 4

index_by_idMethod · 0.80
push_backMethod · 0.80
getMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected