0

I have a format like this:

a: 1 b: 1 c: 1 foo: 1
a: 2 b: 2 c: 2 foo: 1
a: 3 b: 3 c: 3 

Basically some documents have foo and others don't. I would like to return all documents, but limit the number of documents containing foo with 1 to the first 20.

I've unsuccessfully tried to use slice. Can I get some help?

thecodingmate
  • 331
  • 6
  • 16
  • Though the duplicate has an "odd" question title, it really is about returning "limited lists" in the combined result. It is "possible" as demonstrated by several means, but for your specific case the opening phrase in the answer is more for you and you should instead run "parallel queries". Being one for the `$exists` results of `foo` and one for the rest of the results. Attempt to "merge into arrays" at your own peril. – Neil Lunn Jun 03 '18 at 01:12
  • Thanks, I decided to just do two queries, run toArray(), and combine the results. Easy enough. Keep it simple. Thanks for your help! – thecodingmate Jun 15 '18 at 17:21

0 Answers0