diff --git a/mdb/collection.go b/mdb/collection.go index 57970a8..27d06c4 100644 --- a/mdb/collection.go +++ b/mdb/collection.go @@ -159,6 +159,15 @@ func (c *Collection[T]) Get(tx *Snapshot, id uint64) *T { return c.ByID.Get(tx, item) } +func (c *Collection[T]) Has(tx *Snapshot, id uint64) bool { + if tx == nil { + tx = c.db.Snapshot() + } + item := new(T) + c.setID(item, id) + return c.ByID.Has(tx, item) +} + func (c *Collection[T]) Insert(tx *Snapshot, userItem *T) error { if tx == nil { return c.db.Update(func(tx *Snapshot) error {