I thought this was possible, but looking at this:


It seems like it's impossible. What are the alternatives? I tried to think about the best solutions and it involves querying all documents and then selectively filtering, or making 2 queries instead of just one and combining them both.

I have something like Parent.find().sort().skip().limit(); Basically. I have a Course collection and a Student collection and I want to be able to let Student sort by the course they favorited, but because each student have their own favorites, it can't be done in a straightforward way. I was planning on creating foreign keys and then do a populate() and use the transform option to create a boolean and then sort by the path field like so:

doc = await Parent.populate([{
  path: 'favorites',
  transform: doc => doc == null ? true : false


But it looks like it's not possible. LIMIT_CONSTANT is roughly 20, and I am not sure what the most performant solution would be.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.