DEV Community

Nagarajan R
Nagarajan R

Posted on

Answer: Mongoose - Get list of _ids instead of array of objects with _id

Group.find({program: {$in: [...]}})
  .distinct('_id')

db.collection.distinct(field, query)

Finds the distinct values for a specified field across a single collection and returns the results in an array.

Read more.

Top comments (0)