crud icon indicating copy to clipboard operation
crud copied to clipboard

Add update_object operation

Open savinov opened this issue 2 years ago • 2 comments

Please add update_object operation similarly to upsert_object: https://github.com/tarantool/crud#upsert

savinov avatar Jun 21 '23 12:06 savinov

The reason why there is insert_object, replace_object and upsert_object and no update_object and delete_object is as follows.

The syntax for insert/replace is space:insert(tuple)/space:replace(tuple). upsert is replace+update, so its syntax is space:upsert(tuple, ops). For insert, replace and upsert it is expected that user should provide a tuple since one may not exist yet.

On the other hand, the syntax for update/delete is index:update(key, ops)/space:delete(key). It is expected that tuple should already exist, so it may be accessed by its key. The object isn't used here, so there is no corresponding _object method yet. On the other hand, we may implement primary key extraction from the key-value object.

Two separate questions could be considered here:

  • allowing to specify index key with {key = value} map for update and delete (through update_object and delete_object ),
  • allowing to use non-primary index for update and delete.

I think we'll discuss these features with product team and then decide either we should or shouldn't support them.

DifferentialOrange avatar Jun 21 '23 13:06 DifferentialOrange

On the other hand, we may implement primary key extraction from the key-value object.

That's the purpose of the issue.

savinov avatar Jun 24 '23 20:06 savinov