tator
tator copied to clipboard
Evaluate attribute dependencies + mutability
Problem
Some attribute values are solely based on the values of others. Related, but not addressed, is some attribute values are limited solely based on others attribute values.
Exploration space
Implement a microservice (potentially something like WASM runners or node.js runners) which allows for generic logic to be specified to update attribute values upon POST or PATCH. This logic could be supplied by the frontend at POST/PATCH time or potentially stored in the AttributeType definition itself.
An interface could be designed for these worklets such that a POST or PATCH invokes this user supplied code which updates the object prior to insertion into the database. The code is user supplied so there is flexibility in implementation without having to hard-code support for various dependency models into the backend.
Architectural justification
This is similar to the concept of a database trigger. When a row is modified the database can elect to have a trigger which has a last call opportunity to set values in the row prior to committing. Common use-cases are things like 'modified time' or 'modified by'.
Example
A attribute dependency worklet could be defined on the object to set an attribute called "Max Value" to the maximum value specified in some set of the object's other attributes. In this simple case, it might be interesting to make "Max Value" a read-only attribute.
Why bother?
By specifying the attribute dependency model in the data modal (LocalizationType) and allowing it to be defined in userspace/client code by deferred execution one gets flexibility but assurances in the data model. If a POST occurs via any mechanism the rows in the database are properly filled in with the dependency worklet.