Home > Software design >  MongoDB aggregate returning an empty array
MongoDB aggregate returning an empty array

Time:11-13

So, my problem is, that in MongoDB that .aggregate() function is not working

Heres some pictures:

mongo shell friendRequests collection users collection

You can see what a tried on the first picture

CodePudding user response:

When using "$lookup", it's important that both "localField" values and "foreignField" values have the same type.

In this case, "localField" is a string and "foreignField" is an ObjectId.

It's probably best for queries to use ObjectId's for both.

  • Related