Closed cbndr closed 5 years ago
You could use Select
with Each
and return an error:
func isEmpty(db *storm.DB) (bool, error) {
var notEmptyError = errors.New("not empty")
err := db.Select().Each(new(User), func(record interface{}) error {
return notEmptyError
})
if err != nil && err != notEmptyError {
return false, err
}
return err == notEmptyError, nil
}
Thanks @asdine - works like a charm
What is the best method to verify whether a node/bucket is empty? Counting is overkill, as any element means the node/bucket is NOT empty.