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

NodeJS Query For Loop Example Shows Incorrect Syntax

    XMLWordPrintable

Details

    Description

      The example given in this page:

      var N1qlQuery = couchbase.N1qlQuery;
      // ...
      query = N1qlQuery.fromString('SELECT name, email FROM default LIMIT 10');
      bucket.query(query, function(err, rows, meta) {
      for (row in rows)

      { console.log('Name: %s. Email: %s', row.name, row.email); }

      });

      is not correct; when executed will return

      "undefined undefined"

      printed repeatedly by the "console.log" call for however many rows are returned in the result set.

      The correct syntax is:

      var N1qlQuery = couchbase.N1qlQuery;
      // ...
      query = N1qlQuery.fromString('SELECT name, email FROM default LIMIT 10');
      bucket.query(query, function(err, rows, meta) {
      for (row in rows)

      { console.log('Name: %s. Email: %s', rows[row].name, rows[row].email); }

      });

      Reporter: Morris Schreibman
      E-mail: mschreib_il@yahoo.com

      Attachments

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

        Activity

          There are no commits yet on this issue.

          People

            richard.smedley Richard Smedley
            mschreib_il Morris Schreibman
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty