import "github.com/cockroachdb/cockroach/pkg/roachpb" request := &roachpb.BatchRequest{} request.Add(&roachpb.GetRequest{ Span: roachpb.Span{ Key: []byte("key1"), }, }) request.Add(&roachpb.PutRequest{ Span: roachpb.Span{ Key: []byte("key2"), }, Value: []byte("value"), })
import "github.com/cockroachdb/cockroach/pkg/roachpb" request := &roachpb.BatchRequest{} request.Add(&roachpb.DeleteRangeRequest{ Span: roachpb.Span{ Key: []byte("key1"), EndKey: []byte("key4"), }, ReturnKeys: true, })In this example, a BatchRequest is created and a DeleteRange operation is added to it. The DeleteRange operation deletes all keys between "key1" (inclusive) and "key4" (exclusive) and returns the keys that were deleted.