Uploaded image for project: 'Couchbase node.js Client Library'
  1. Couchbase node.js Client Library
  2. JSCBC-1164

Provide a default implementation of the `Cas` interface

    XMLWordPrintable

Details

    • Improvement
    • Resolution: Unresolved
    • Trivial
    • 4.x
    • None
    • library
    • 0

    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.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            jared.casey Jared Casey
            JesusTheHun Jonathan MASSUCHETTI
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Time Tracking

                Estimated:
                Original Estimate - 1h
                1h
                Remaining:
                Remaining Estimate - 1h
                1h
                Logged:
                Time Spent - Not Specified
                Not Specified

                Gerrit Reviews

                  There are no open Gerrit changes

                  PagerDuty