WARNING: value functions are DEPRECATED and will be removed soon. #296
Replies: 2 comments 12 replies
-
We are removing schema literal value functions and directing users to define these via the table constructor. There should be no loss of functionality. It is just relocated to the Table constructor params where you can define your value template functions via the params {value: Function}. The reason we are doing this is to support schemas being persisted to storage for tooling to assist in schema creation and management. For this, they must be static literal with no-embedded functions. Adding embedded functions blocks this functionality. See the table constructor doc: Value Template FunctionValue templates are defined in the schema for model fields. These are typically literal strings with property variable references. In some use cases, more complex logic for a value template requires a function to calculate the property value at runtime. The Table constructor params.value function provides a centralized place to evaluate value templates. It will be invoked for fields that define their value template to be true. The value template function is called with the signature:
The value template should return a string to be used for the given fieldName. The properties and params are corresponding arguments given to the API. |
Beta Was this translation helpful? Give feedback.
-
There isn't a Table params.default callback function in the code currently. |
Beta Was this translation helpful? Give feedback.
-
Hi,
Why are you going to remove value functions?
The perfect use case is for dynamical and automatic sharding of an index via partition key.
For example if I want to have a partition with all the user in updating order (imagine millions of users) i have to shard the data for example by year and week:
The alternative is to have to remember every model partition key and save or update the PKs every time I need a different shard (now I have 10 models sparse in 12 indexes in one table). IMHO value functions are very valuable for reducing code complexity and footprint, and shouldn't be removed 😅.
Cheers.
Beta Was this translation helpful? Give feedback.
All reactions