Пример #1
0
func (this *BoltHelper) Commit(tx *bolt.Tx) error {

	if err := tx.Commit(); err != nil {
		this.Logger.Error("[ERROR] Commit Tx Error %v", err)
		tx.Rollback()
		return err
	}

	return nil
}
Пример #2
0
func (this *BoltHelper) Traverse(tablename string, tx *bolt.Tx) func() ([]byte, []byte) {

	var c *bolt.Cursor

	b := tx.Bucket([]byte(tablename))
	c = b.Cursor()

	k, v := c.First()
	return func() ([]byte, []byte) {

		if k != nil {
			k1, v1 := k, v
			k, v = c.Next()
			return k1, v1
		}

		return nil, nil

	}

}