ayon-backend icon indicating copy to clipboard operation
ayon-backend copied to clipboard

Selective patching of entity.data

Open martastain opened this issue 10 months ago • 1 comments

Story

The current implementation of patching entity data field supports updating dictionary values at a single depth level. While users can set values like data["something"] = "value", the API does not support updating nested dictionary values such as data["something"]["nested"] = value. This limitation restricts the flexibility and efficiency of data updates, especially when dealing with complex data structures.

Proposed solution

Enable Nested Patching:

  • Modify the patch functionality to allow for deeper nested updates using a dot notation. For example, updating with data = {"something.nested": value} should directly target and modify the nested key.
  • Allow setting a nested value to None as a means to unset that specific key.

martastain avatar Apr 16 '24 12:04 martastain

  • Allow setting a nested value to None as a means to unset that specific key.

I'm not sure if that's the best way to do this if None is also a valid value for that key? I wonder if we should have a dedicated value or special syntax for unsetting a key like that. I believe MongoDB has something like $unset, see e.g. here?

BigRoy avatar Apr 16 '24 12:04 BigRoy