immudb icon indicating copy to clipboard operation
immudb copied to clipboard

client.ExecAll support for INSERT/UPDATE/DELETE

Open cezar-radan opened this issue 2 years ago • 2 comments

What would you like to be added or enhanced ExecAll command - should be enhanced Would be nice if this command will allow to perform not only INSERT /UPDATE on Keys and Sets but also to perform Keys DELETE operation.

Why is this needed ExecAll is an atomic TRANSACTION. In a transaction maybe you want to replace some keys (delete old ones and create new ones).
Of course, now, you can do the operation in two steps (delete + insert) and if the insert fails to do additional work but would be nice if the work will be atomic (same transaction)

Additional context

cezar-radan avatar Jul 05 '22 09:07 cezar-radan

thanks for requesting the enhancement @cezar-radan

While deletion doesn't have its own operation in ExecAll, it's still possible to mark a key-value entry as deleted by setting the deleted flag in the metadata of the entry:

&schema.ExecAllRequest{
		Operations: []*schema.Op{
			{
				Operation: &schema.Op_Kv{
					Kv: &schema.KeyValue{
						Key:   []byte(`key`),
						Value: []byte(`val`),
						Metadata: &schema.KVMetadata{
							Deleted: true,
						},
					},
				},
			},
		},
	}

Interactive KV transactions are already on the roadmap for next immudb releases, then ExecAll may just be used under very specific scenarios i.e. when the assigned Tx ID needs to be known... Otherwise constrained writes or interactive transactions will be the easiest way to go

jeroiraz avatar Jul 05 '22 15:07 jeroiraz

Hi, Thank you very much for your fast answer and for the hint.

cezar-radan avatar Jul 06 '22 05:07 cezar-radan

@jeroiraz do we close this issue or are we planning some changes?

emkaminsk avatar Sep 07 '22 16:09 emkaminsk