I have a collection of persons with a group property. Group value is a random string, which I don't know when I make my query. Some persons group values will possibly be the same.
I want to write a query to retrieve only one person per group (which person is returned in the group is non relevant for the moment).
I suppose I have to write some kind of aggregation. But I only read about examples aggregating on known values... Instead I need to aggregate on unknown values...
My schema is something like:
const schemaPersons = new Schema({
name: {
type: String,
required: true,
},
group: {
type: String,
},
};