Sonam
0
Q:

MongoDB - Unwind array using aggregation and remove duplicates

## MongoDB - Unwind array using aggregation and remove duplicates
db.users.aggregate([
  { $unwind: '$data' },
  { $group: { _id: '$_id', data: { $addToSet: '$data' } } }
]);
0

New to Communities?

Join the community