feat(cmd): added listcmd and refactored transactions to use TransactionArgs
This commit is contained in:
parent
cc206a7c8a
commit
2da42de7ab
5 changed files with 146 additions and 23 deletions
14
cmd/del.go
14
cmd/del.go
|
|
@ -36,9 +36,17 @@ var delCmd = &cobra.Command{
|
|||
|
||||
func del(cmd *cobra.Command, args []string) error {
|
||||
store := &Store{}
|
||||
return store.Transaction(args[0], false, func(tx *badger.Txn, k []byte) error {
|
||||
return tx.Delete(k)
|
||||
})
|
||||
|
||||
trans := TransactionArgs{
|
||||
key: args[0],
|
||||
readonly: false,
|
||||
sync: false,
|
||||
transact: func(tx *badger.Txn, k []byte) error {
|
||||
return tx.Delete(k)
|
||||
},
|
||||
}
|
||||
|
||||
return store.Transaction(trans)
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue