3 ms·
They should not try to emulate SQL databases, there are other ways to manage inventory without transactions. One way is to add a field to an item that show its
by codedokode 9y ago
They should not try to emulate SQL databases, there are other ways to manage inventory without transactions.
One way is to add a field to an item that show its status: whether it is in a warehouse, in someone's cart, ordered or sold. Then adding an item to a cart means updating those fields. There probably is a way to do several similar updates atomically.
Another way is to use append-only collection, that keeps a list of events, like "Item X added to cart Y", "Item X sent to delivery".
But I guess when there are more entities and relations this would become too complex to manage. While SQL databases have no problems with hundreds of tables and thousands of columns.
- elmigranto 9y ago> Then adding an item to a cart means updating those fields. There probably is a way to do several similar updates atomically. Atomicity is document level, not collection level. So you can't update multiple documents atomically. Or do you plan on having `{status: 'in-cart', cartOwner: 'customer-id' | null}` and single document for every stocked item (like 1k copies of the same book would be 1k db documents and you also have all those sold from before)? > Another way is to use append-only collection How does it help with overselling? To decide if it's okay to append, you have to know if current number of items is greater than 0 (don't forget to lock other clients out of appending this whole process, so they wait for you to finish).