For a specific bucket, I wish to get data from multiple documents. I was able to achieve this functionality using bulk operation ( i.e. getMulti method). Now I wish to get only specific fields of each document (the nested path of each of which may differ). I am able to achieve both these functionalities individually using either bulk operation or subdocument api. But, is there any way to get the benefit of both these methods simultaneously ?
As an example, let’s say this is sample document -
I needed to fetch only “table.op1.a1”. I can do this using subdocument api.
I want to do the same for multiple documents. Can it be done?
Note - op1, a1 etc are variable, and differ for every document.
The Node.js SDK internally handles batching without any additional effort required by the developer. The getMulti operation is provided as a convenience method, but if you inspect its implementation it simply performs a number of asynchronous operations and waits for them to all complete. You can implement the same form of behaviour for subdocument operations by performing a number of subdocument lookups and waiting for them all to complete.
That’s great. Just one more thing - What’s the max number of requests (subdocument api requests for Get or Upsert) which I can make in parallel? And if there’s a max limit of parallel requests which Couchbase can handle, why there’s no such max limit written in getMulti method’s implementation?
There is no strong limit on the maximum number of parallel requests, you will note that we simply set the batch size to the number of requests by default. The major limitation would be in the size of your network buffers and the amount of memory available to hold the requests.