Reputation: 309
I'm working in NodeJS and I have a working CouchDB connection.
I can get a reference to a collection like so:
var myCluster = await couchbase.connect(serverHttp, authentication);
const myBucket = myCluster.bucket("myBucketName", { timeout: 10000 });
const myCollection = myBucket.defaultCollection();
This all works as I can make a call like so:
const res = await myCollection.get("testKey");
and indeed I see that res contains the one document from the database which has its id as "testKey".
Question: How can I run queries on myCollection?
For instance, the most trivial example, how could I retrieve from myCollection all of the documents in it?
Or, if this is not possible, how could I achieve the same by using myCluster?
This is not working for me:
var result = myCluster.query("SELECT myBucketName.* FROM myBucketName");
Thanks for any help.
ADDENDUM: ok, I have found this way that works for me:
var result = await myCluster.query("SELECT META().id, * FROM myBucketName");
I still have a lot to learn!
Upvotes: 1
Views: 29