MCPcopy
hub / github.com/etcd-io/bbolt / Delete

Method Delete

cursor.go:140–155  ·  view source on GitHub ↗

Delete removes the current key/value under the cursor from the bucket. Delete fails if current key/value is a bucket or if the transaction is not writable.

()

Source from the content-addressed store, hash-verified

138// Delete removes the current key/value under the cursor from the bucket.
139// Delete fails if current key/value is a bucket or if the transaction is not writable.
140func (c *Cursor) Delete() error {
141 if c.bucket.tx.db == nil {
142 return errors.ErrTxClosed
143 } else if !c.bucket.Writable() {
144 return errors.ErrTxNotWritable
145 }
146
147 key, _, flags := c.keyValue()
148 // Return an error if current value is a bucket.
149 if (flags & common.BucketLeafFlag) != 0 {
150 return errors.ErrIncompatibleValue
151 }
152 c.node().del(key)
153
154 return nil
155}
156
157// seek moves the cursor to a given key and returns it.
158// If the key does not exist then the next key is used.

Callers

nothing calls this directly

Calls 4

keyValueMethod · 0.95
nodeMethod · 0.95
delMethod · 0.80
WritableMethod · 0.45

Tested by

no test coverage detected