node-ottoman icon indicating copy to clipboard operation
node-ottoman copied to clipboard

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

Open xavierchow opened this issue 3 years ago • 7 comments

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,

  • Enhancement on FindByIdOptions to allow querying the CAS
  • Enhancement on updateById to allow passing a CAS(probably via MutationFunctionOptions)?

xavierchow avatar Apr 24 '22 08:04 xavierchow

@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 ?

AV25242 avatar Apr 25 '22 17:04 AV25242

@AV25242

I think we can expose it, no problem.

gsi-alejandro avatar Apr 25 '22 18:04 gsi-alejandro

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

gsi-alejandro avatar May 03 '22 16:05 gsi-alejandro

@gsi-alejandro hey, any updates about this?

xavierchow avatar Jul 28 '22 04:07 xavierchow

+1

superbogy avatar Sep 22 '22 07:09 superbogy

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

AV25242 avatar Oct 10 '22 20:10 AV25242

another solution is:

  • let IDocument hold the CAS as its internal data
  • add a boolean parameter to IDocument.save() method to enable CAS check when updating

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

bsdelf avatar Mar 15 '23 07:03 bsdelf