Uploaded image for project: 'Couchbase Documentation'
  1. Couchbase Documentation
  2. DOC-6703

Can we please have a working paste-and-run Node 3.0 code sample?

    XMLWordPrintable

Details

    Description

      Something along the lines of this, with best practices, if possible (I'm not a Node expert, can't offer that):

      ======

      'use strict';
      var couchbase = require('couchbase');
      // Create a Couchbase Cluster connection
      var cluster = new couchbase.Cluster('couchbase://localhost',

      { username: 'Administrator', password: 'password' }

      );
      // Open a specific Couchbase bucket, `travel-sample` in this case.
      var bucket = cluster.bucket('travel-sample');
      // And select the default collection
      var collection = bucket.defaultCollection();
      // upsert document
      async function upsertDocument(key, value)

      { var result = await collection.upsert(key, value); }

      upsertDocument("my-document",

      {name: 'mike'}

      );
      // get document
      async function getDocument()
      {
      await collection.get('airline_10123', function(err, result)

      { if (err) throw err; console.log(result); }

      );
      }
      getDocument();

      =======

      If someone tries to use our current example, they won't get far. It's pretty frustrating.

      Reporter: Oleg Kuzmin
      E-mail: oleg.kuzmin@couchbase.com

      Attachments

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

        Activity

          oleg.kuzmin Oleg Kuzmin (Inactive) created issue -
          richard.smedley Richard Smedley made changes -
          Field Original Value New Value
          Assignee Amarantha Kulkarni [ amarantha.kulkarni ] Richard Smedley [ richard smedley ]
          richard.smedley Richard Smedley made changes -
          Component/s server dev guide and SDKs [ 11814 ]
          Epic Link CBD-2844 [ 96901 ]
          Sprint DOC-2020-S9-May17 [ 1049 ]
          Labels collector-de2e9313 collector-de2e9313 node.js
          Priority Test Blocker [ 6 ]
          richard.smedley Richard Smedley made changes -
          Sprint DOC-2020-S9-May17 [ 1049 ] DOC-2020-S10-May31 [ 1060 ]
          richard.smedley Richard Smedley made changes -
          Status Open [ 1 ] In Progress [ 3 ]
          richard.smedley Richard Smedley made changes -
          Resolution Fixed [ 1 ]
          Status In Progress [ 3 ] Resolved [ 5 ]

          People

            richard.smedley Richard Smedley
            oleg.kuzmin Oleg Kuzmin (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty