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

All documents are created inside default collection.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Critical
    • 3.1.1
    • 3.0.6, 3.0.7
    • lcb, library
    • None
    • 1
    • SDK 44: Txns, SDK 3.1, Docs, SDK48: FTS Score/Incl, Docs., SDK51: FLEpt1, Txns Test Compl, SDK2: FLEpt2, TxnsTest

    Description

      During the test for Ottoman, it was found that specifying a collection name that does not exist or scenario where scopes and collections are unsupported. Documents still gets created probably inside the default collection.

      example see the code below where a collection called "Airline" is referred. When the code is run against CB server that does not support collection the document is still created.

       

      Code sample Courtesy  - Cloud examples.

      var couchbase = require('couchbase');// Update this to your cluster
       
      const endpoint = 'localhost'
      const username = 'Administrator'
      const password = 'password'
      const bucketName = 'travel'// User Input ends here.// Initialize the Connection
      var cluster = new couchbase.Cluster('couchbases://' +endpoint+'?ssl=no_verify&console_log_level=5', {username: username, password: password});
      var bucket = cluster.bucket(bucketName);
      var collection = bucket.collection('Airline');function start(){
        console.log('start');
        return new Promise( (resolve, reject) => { resolve(); });
      }async function run(){
          // Create a N1QL Primary Index (but ignore if it exists)
        try {
          await cluster.queryIndexes().createPrimaryIndex(bucketName, {ignoreExists: true});
        } catch (e) {
        }  // Create and store a document
        try {
          var result  = await collection.upsert('user:king_arthur', {
              'name': 'Arthur', 'email': 'kingarthur@couchbase.com', 'interests': ['Holy Grail', 'African Swallows']
          });  } catch (e) {
          throw(e);
        }    // Load the Document and print it
          // Prints Content and Metadata of the stored Document
        try {
          let getResult = await collection .get('user:king_arthur');
          console.log('Got: ');
          console.log(getResult);
        } catch (e) {
          console.log(e);
          throw(e);
        }  // Perform a N1QL Query
        const options = { parameters: ['African Swallows'] };
        try {
          let queryResult = await cluster.query('SELECT name FROM '+bucketName +' WHERE $1 in interests LIMIT 1', options);
          queryResult.rows.forEach((row) => {
            console.log('Query row: ', row)
          });
        } catch (e) {
          console.log(e);
          throw(e);
        }
      }
      start().then(run).then(() => { console.log("closing..."); cluster.close();});
      
      

      Attachments

        Issue Links

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

          Activity

            People

              brett19 Brett Lawson
              arun.vijayraghavan Arun Vijayraghavan (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes

                  PagerDuty