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

          No work has yet been logged on this issue.

          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