pub(super) fn get_count_by_prefix(
    db: &Db,
    tree: &str,
    prefix: &[u8]
) -> Result<usize, AppError>
Expand description

get the count N by scanning the prefix of the key

§Examples

// get the third comment's upvotes of the post 1.
// key: pid#cid#uid
let prefix = [&u32_to_ivec(1), &u32_to_ivec(3)].concat();
let upvotes = get_count_by_prefix(&db, "comment_upvotes", &prefix).unwrap_or_default();