MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / list_insert_container

Function list_insert_container

nodedb-crdt/src/list_ops.rs:37–48  ·  view source on GitHub ↗

Insert a LoroMap container into a block list at the specified index. Returns the created LoroMap so callers can populate its fields.

(
    doc: &LoroDoc,
    collection: &str,
    row_id: &str,
    list_path: &str,
    index: usize,
)

Source from the content-addressed store, hash-verified

35///
36/// Returns the created LoroMap so callers can populate its fields.
37pub fn list_insert_container(
38 doc: &LoroDoc,
39 collection: &str,
40 row_id: &str,
41 list_path: &str,
42 index: usize,
43) -> Result<LoroMap> {
44 let list = get_movable_list(doc, collection, row_id, list_path)?;
45 let idx = index.min(list.len());
46 list.insert_container(idx, LoroMap::new())
47 .map_err(|e| CrdtError::Loro(format!("list insert container at {idx}: {e}")))
48}
49
50/// Delete an element from a block list at the specified index.
51pub fn list_delete(

Callers 2

Calls 2

get_movable_listFunction · 0.85
lenMethod · 0.45

Tested by 1