I'd like to store a number of product inventories. Each inventory is keyed on a product ID, and each product has arbitrary attributes. I want to take proposed changes to products (which may be several per second) and apply them to their respective inventories. If the data in the proposed change matches the stored data, nothing should happen. If they don't match:
- The stored product should be updated with the data in the change
- The version number of that inventory should be incremented by one
- The product should be given the new version number, so I can return all products that have changed between two arbitrary inventory versions
In either case, a result indicating which case occurred should be returned.
Proposed product data is considered different if:
- an attribute in the change has a different value; or
- the change contains an attribute that hasn't been stored yet
There are two requirements that I'm particularly interested in:
I don't want either the round trip nor the resulting race condition of retrieving the existing data, comparing it in the application server, and then updating it if necessary
The version number must be increased monotonically, regardless of which application server node submits the change
Since ArangoDB has some built-in scripting capabilities, would it be a good match for this scenario?