Returning Multiple Documents in a single view

Hello there,

Is there a way where multiple documents or an array of documents be returned in a single cblite view?

Can you describe in more detail what you want to do?

Hi Jens,

We have appointments scheduled for each user for a single day in one document. Every document has say 5-6 appointments. When the user logs into the application on the tablet, we need to display all the appointments for 3 days and a left to right swipe would display the next 3 days. If the user logs in today, the user needs to see all the visits for Dec 9th, Dec 10th and Dec 11th. We have Key defined as username::12092016, username::12102016, username::12112016 and so on. Instead of making 3 different calls to get these documents one by one, can we emit all 3 together in a single view?

Oh, I see, you mean “in a single query”.

Change the date strings so they’ll sort correctly. So instead of 12092016, emit 20161209. Then you can get the appointments for a user and a date range in one query by doing

query.startKey = "username::20161209";
query.endKey = "username::20161211";

Or if you know you want three appointments (not three days, which might not be the same thing), set limit=3 instead of setting the endKey.

Thank you, I will try this.