node-ottoman
node-ottoman copied to clipboard
Is there a way to retrieve the CAS from the document?
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
FindByIdOptionsto allow querying the CAS - Enhancement on
updateByIdto allow passing a CAS(probably viaMutationFunctionOptions)?
@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
I think we can expose it, no problem.
Next release we plan to expose a way to return the CAS value when available.
@gsi-alejandro hey, any updates about this?
+1
@gsi-alejandro where are we on this ? cc @ejscribner @thejcfactor
another solution is:
- let
IDocumenthold theCASas its internal data - add a boolean parameter to
IDocument.save()method to enableCAScheck when updating
therefore SDK user won't explicitly use the CAS at all.