Colleciton.Has convenience function
This commit is contained in:
parent
c2828592ac
commit
91b2ba30f6
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user