Description
Using the SDK, if you want to provide a serialized `cas`, you cannot pass it directly to a couchbase function :
const result = await cb.collection('my_collection').mutateIn(docKey, [
|
MutateInSpec.replace('someProp', somePropValue),
|
], {
|
cas: CouchbaseCas.from(myCasString), <= I cannot pass a string directly, it requires a object that implements the Cas interface
|
});
|
I've made a quick implementation :
import { Cas } from "couchbase";
|
|
export class CouchbaseCas implements Cas {
|
private readonly cas: string;
|
|
constructor(casString: string) {
|
this.cas = casString;
|
}
|
|
static from(casString: string) {
|
return new CouchbaseCas(casString);
|
}
|
|
toJSON() {
|
return this.cas;
|
}
|
|
toString() {
|
return this.cas;
|
}
|
}
|
It would be nice to provide a default implementation, since virtually all SDK users will need one.