Unable to set up local service

query

#1

From https://docs.couchbase.com/nodejs-sdk/2.6/sample-app-backend.html

Clarifying this part

The statement is ready! You can execute this statement by wrapping it in a `couchbase.N1qlQuery.fromString()` . Here it is very simple, no placeholders and no particular tuning of the query is necessary, so the simple method will be used:

```
bucket.query(q, callbackFn)
```

The results of the query are returned in a list of records in the callback, which then is added to the response:

```
function(err, rows) {
    if (err) {
      res.status(500).send({
        error: err
      });
      return;
    }

    res.send({
      data: rows,
      context: [qs]
    });
  }
```

#2
const express = require('express');
 const couchbase = require('couchbase');
const cluster = new couchbase.Cluster('couchbase://localhost/');
    cluster.authenticate('username', 'password');

const bucket = cluster.openBucket('bucketname', function(err) {
    if (err) {
        console.log('Bucket connection failed', err);
        return;
    }
        console.log('Connected to Couchbase!');
    });

const app = express();

    app.get('/',function(req,res){

        var qs;

        qs = "SELECT * FROM bucketname";

const q = couchbase.N1qlQuery.fromString(qs);
        bucket.query(q, function(err, rows) {
            if (err) {
                res.status(500).send({
                    error: err
                });
                return;
            }
            console.log("Got rows: %j", teams);
            res.json({
                data: teams
            });
        });
    });

    app.listen(3000, function () {
        console.log('App listening on port 3000!');
    });

#3

Hi @Coucher,

Do you have a question, or are you trying to submit some feedback about the documentation?


#4

Hi Matthew,

Could not delete topic …

What we want from Couchbase is this :

  1. New Zealand
  2. Ireland
  3. Wales

as in [https://www.world.rugby/rankings/mru](http://)

What we have is this :

{“data”:[{“team”:“New Zealand”},{“team”:“Ireland”},{“team”:“Wales”}]}

Learning to walk…