couchbaselabs / node-ottoman

Node.js ODM for Couchbase
https://ottomanjs.com/
Apache License 2.0
287 stars 98 forks source link

Is there a way to retrieve the CAS from the document? #652

Open xavierchow opened 2 years ago

xavierchow commented 2 years ago

As one of the approaches to concurrency-safe mutating document, I need to get the CAS from the document and replace the doc with it.

I didn't find a documentation about the CAS retrieving, digging into the code it seems the findById only gets back the value(that is replaced by content according to latest sdk) https://github.com/couchbaselabs/node-ottoman/blob/d8a4936ed996526735bae3fca478fda1516d582c/src/model/create-model.ts#L190-L192

Will it be a good idea to have the ottoman to support both query CAS and update with it? my two cents,

AV25242 commented 2 years ago

@gsi-alejandro can you please address this, I think we dont have this as a feature today like @xavierchow had mentioned. Is there a limitation as to not exposing the getOptions ?

gsi-alejandro commented 2 years ago

@AV25242

I think we can expose it, no problem.

gsi-alejandro commented 2 years ago

Next release we plan to expose a way to return the CAS value when available.

xavierchow commented 2 years ago

@gsi-alejandro hey, any updates about this?

superbogy commented 2 years ago

+1

AV25242 commented 2 years ago

@gsi-alejandro where are we on this ? cc @ejscribner @thejcfactor

bsdelf commented 1 year ago

another solution is:

therefore SDK user won't explicitly use the CAS at all.