To run a n1ql query in nodejs we do
query = N1qlQuery.fromString('SELECT name, email FROM users WHERE name=$1');
bucket.query(query, ['Monty Python'], function(err, rows) {
// ...
});
As bucket
is a opened bucked
bucket = cluster.openBucket('users');
How can we tell N1qlQuery that query to the current opened bucket that means :
bucket1 = cluster.openBucket('users1');
bucket2 = cluster.openBucket('users2');
query = N1qlQuery.fromString('SELECT name, email FROM **CURRENT_OPENED_BUCKET** WHERE name=$1');
// Query on users1 bucket
bucket1.query(query, ['Monty Python'], function(err, rows) {
// ...
});
// Query on users2 bucket
bucket2.query(query, ['Monty Python'], function(err, rows) {
// ...
});