Exemple #1
0
// CounterDelete deletes a counter from a scope.
func (b *BotDB) CounterDelete(scope, counterName string) error {
	return b.db.Batch(func(tx *bolt.Tx) error {
		counters, err := getCountersBucket(tx, scope)
		if err != nil {
			return err
		}

		counterNameBytes := []byte(counterName)
		bucket := counters.Bucket(counterNameBytes)
		if bucket == nil {
			return ErrCounterNotFound
		}

		return helpers.DeleteBucketWrap(counters, counterNameBytes)
	})
}
Exemple #2
0
// MapDelete deletes a map from a scope.
func (b *BotDB) MapDelete(scope, mapName string) error {
	return b.db.Batch(func(tx *bolt.Tx) error {
		maps, err := getMapsBucket(tx, scope)
		if err != nil {
			return err
		}

		mapNameBytes := []byte(mapName)
		bucket := maps.Bucket(mapNameBytes)
		if bucket == nil {
			return ErrMapNotFound
		}

		return helpers.DeleteBucketWrap(maps, mapNameBytes)
	})
}
Exemple #3
0
// ListDelete deletes a list from a scope.
func (b *BotDB) ListDelete(scope, listName string) error {
	return b.db.Batch(func(tx *bolt.Tx) error {
		lists, err := getListsBucket(tx, scope)
		if err != nil {
			return err
		}

		listNameBytes := []byte(listName)
		bucket := lists.Bucket(listNameBytes)
		if bucket == nil {
			return ErrListNotFound
		}

		return helpers.DeleteBucketWrap(lists, listNameBytes)
	})
}