aboutsummaryrefslogtreecommitdiff
path: root/rwtransaction.go
diff options
context:
space:
mode:
Diffstat (limited to 'rwtransaction.go')
-rw-r--r--rwtransaction.go20
1 files changed, 15 insertions, 5 deletions
diff --git a/rwtransaction.go b/rwtransaction.go
index 2485c62..7911188 100644
--- a/rwtransaction.go
+++ b/rwtransaction.go
@@ -70,19 +70,29 @@ func (t *RWTransaction) Put(name string, key []byte, value []byte) error {
return &Error{"data too large", nil}
}
- // Insert a new node.
+ // Move cursor to correct position.
c := b.cursor()
c.Get(key)
+
+ // Insert the key/value.
t.node(c.stack).put(key, key, value, 0)
return nil
}
func (t *RWTransaction) Delete(name string, key []byte) error {
- // TODO: Traverse to the correct node.
- // TODO: If missing, exit.
- // TODO: Remove node from page.
- // TODO: If page is empty then add it to the freelist.
+ b := t.Bucket(name)
+ if b == nil {
+ return &Error{"bucket not found", nil}
+ }
+
+ // Move cursor to correct position.
+ c := b.cursor()
+ c.Get(key)
+
+ // Delete the node if we have a matching key.
+ t.node(c.stack).del(key)
+
return nil
}