I am new to Couchbase and just finished setting everything up.
import couchbase from 'couchbase';
const myCluster = new couchbase.Cluster('couchbase://127.0.0.1');
myCluster.authenticate('my_username', 'my_password');
export default myCluster;
This is the file where I init my cluster. In another file, I try to perform the following query among my users database:
import couchbase from 'couchbase';
import myCluster from '/path/to/couchbaseInit.js';
const N1qlQuery = couchbase.N1qlQuery;
const getDbIdQuery = "SELECT meta(`users`).id" +
"FROM `users`" +
"WHERE googleId=$UID";
const getDbId = uid => new Promise((resolve, reject) => {
myCluster.openBucket('users', '')
.query(
N1qlQuery.fromString(getDbIdQuery),
{parameters: {UID: uid}},
(error, results) => {
if (error) reject(error);
else resolve(results[0].id);
}
);
});
Calling this method returns a “Ambiguous reference to field googleId” in Node console. Though from the web console, it returns the correct results :