Can Couchbase stream the result of a query?

I want to make a query to Couchbase, for example for a list of posts, ordered by most recently updated first, and then receive the result from Couchbase as a node js stream, that I can pipe to an http2 stream to send to the user’s browser. Is that possible ?
The objective is to have low memory usage because at any given time only one document will be handled by my application server, and I can send the documents to the user’s browser one by one in small chunks.

1 Like

Hey @mfresh,

That is definitely possible. The result of calling .query() in the SDK is actually a “StreamablePromise”, which means you are able to await it to receive the results all at once, but you are also able to use .on(‘row’), .on(‘meta’) and .on(‘end’).

Cheers, Brett

1 Like

Great, I will try that! Thanks!