Reputation: 885
I have a model as follow:
var GamePlayerSchema = new Schema({
game: {
type: Schema.ObjectId,
ref: 'Game',
required:true
},
group: {
type: Schema.ObjectId,
ref: 'Group'
},
user: {
type: Schema.ObjectId,
ref: 'User'
},
paymentDone: {
type: Boolean,
default:false
}});
In the above model any player can play multiple games.Show when I query the collection user with same name are shown twice if they are registered in two games. To find distinct players I have used the query as below:
GamePlayer.find().distinct('user',function(err, results){
});
But this is not giving the distinct results. How do I achieve distinct result in mongoose.
Upvotes: 0
Views: 4184