You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After triaging/helping solve some user's problem, I feel people use cloudant connector are not aware of couchdb is not designed to change same document frequently and multiple times, couchdb stores status change by creating different documents and including the same unique id to tell that they are attached to the same item, not updating the same document.
Take the following scenario as an example:
A customer places an order, when he/she selects all items and clicks button place order, a purchase document is created as:
Please note the purchase document has a property called order_id to refer to a specific order, and the model property represents its loopback model name
And then clicks button checkout to make payment, two payment documents(since there are two items in the order), with same order_id as the purchase document, are created as:
So in this case, we use purchase and payment as loopback models to represent the events of an order, and an unique identifier(uuid) order_id to make sure related events refer to a certain order.
User can see the status of an order by creating a view of everything you know about an order_id as a ledger containing necessary informations.
How to define those informations are beyond the topic of this issue, and well documented in Cloudant#transaction's doc(check the following link):
Additional information (Node.js version, LoopBack version, etc)
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been closed due to continued inactivity. Thank you for your understanding. If you believe this to be in error, please contact one of the code owners, listed in the CODEOWNERS file at the top-level of this repository.
Feature
Background of feature
After triaging/helping solve some user's problem, I feel people use cloudant connector are not aware of couchdb is not designed to change same document frequently and multiple times, couchdb stores status change by creating different documents and including the same unique id to tell that they are attached to the same item, not updating the same document.
Take the following scenario as an example:
A customer places an order, when he/she selects all items and clicks button
place order
, a purchase document is created as:Please note the purchase document has a property called
order_id
to refer to a specific order, and themodel
property represents its loopback model nameAnd then clicks button
checkout
to make payment, two payment documents(since there are two items in the order), with sameorder_id
as the purchase document, are created as:So in this case, we use
purchase
andpayment
as loopback models to represent the events of an order, and an unique identifier(uuid)order_id
to make sure related events refer to a certain order.User can see the status of an order by creating a view of everything you know about an
order_id
as a ledger containing necessary informations.How to define those informations are beyond the topic of this issue, and well documented in Cloudant#transaction's doc(check the following link):
Additional information (Node.js version, LoopBack version, etc)
The example above is from Cloudant#transaction doc, for details, please refer to https://docs.cloudant.com/transactions.html
Proposal of implementation
loopback model supports defining a property as
uuid
, see https://loopback.io/doc/en/lb3/Model-definition-JSON-file.html#general-property-propertiesWhile I am not sure does it treat
uuid
the same way as what cloudant does with endpointGET _uuids
, will investigate more on that.lib/cloudant.js
to generate an uuid.The text was updated successfully, but these errors were encountered: