Added count functionality
This commit is contained in:
parent
9078335d70
commit
5528c264d3
@ -274,6 +274,10 @@ func (c *Collection[T]) delete(tx *Snapshot, itemID uint64) error {
|
||||
return c.deleteItem(tx, itemID)
|
||||
}
|
||||
|
||||
func (c *Collection[T]) Count(tx *Snapshot) int {
|
||||
return c.ByID.Count(tx)
|
||||
}
|
||||
|
||||
func (c *Collection[T]) getByID(tx *Snapshot, itemID uint64) (*T, bool) {
|
||||
x := new(T)
|
||||
c.setID(x, itemID)
|
||||
|
@ -192,6 +192,11 @@ func (i *Index[T]) List(tx *Snapshot, args *ListArgs[T], out []*T) []*T {
|
||||
return items
|
||||
}
|
||||
|
||||
func (i *Index[T]) Count(tx *Snapshot) int {
|
||||
tx = i.ensureSnapshot(tx)
|
||||
return i.btree(tx).Len()
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
func (i *Index[T]) insertConflict(tx *Snapshot, item *T) bool {
|
||||
|
Loading…
Reference in New Issue
Block a user