@@ -126,6 +126,11 @@ func (t *table) Delete(key []byte) error {
126126// DeleteRange deletes all of the keys (and values) in the range [start,end)
127127// (inclusive on start, exclusive on end).
128128func (t * table ) DeleteRange (start , end []byte ) error {
129+ // The nilness will be lost by adding the prefix, explicitly converting it
130+ // to a special flag representing the end of key range.
131+ if end == nil {
132+ end = ctxcdb .MaximumKey
133+ }
129134 return t .db .DeleteRange (append ([]byte (t .prefix ), start ... ), append ([]byte (t .prefix ), end ... ))
130135}
131136
@@ -224,6 +229,16 @@ func (b *tableBatch) Delete(key []byte) error {
224229 return b .batch .Delete (append ([]byte (b .prefix ), key ... ))
225230}
226231
232+ // DeleteRange removes all keys in the range [start, end) from the batch for later committing.
233+ func (b * tableBatch ) DeleteRange (start , end []byte ) error {
234+ // The nilness will be lost by adding the prefix, explicitly converting it
235+ // to a special flag representing the end of key range.
236+ if end == nil {
237+ end = ctxcdb .MaximumKey
238+ }
239+ return b .batch .DeleteRange (append ([]byte (b .prefix ), start ... ), append ([]byte (b .prefix ), end ... ))
240+ }
241+
227242// ValueSize retrieves the amount of data queued up for writing.
228243func (b * tableBatch ) ValueSize () int {
229244 return b .batch .ValueSize ()
0 commit comments