Node.js 独特查询在Mongoose中不起作用
我有一个模型如下:Node.js 独特查询在Mongoose中不起作用,node.js,mongodb,mongoose,Node.js,Mongodb,Mongoose,我有一个模型如下: 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: {
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
}});
在上面的模型中,任何玩家都可以玩多个游戏。当我查询集合时显示同名用户,如果他们在两个游戏中注册,则显示两次。
为了找到不同的玩家,我使用了如下查询:
GamePlayer.find().distinct('user',function(err, results){
});
但这并没有给出明确的结果。如何在mongoose中获得不同的结果。是一种收集方法,请将查询更改为以下内容:
GamePlayer.distinct('user', function(err, results){
});
是否有收集方法将查询更改为以下内容:
GamePlayer.distinct('user', function(err, results){
});
是否有收集方法将查询更改为以下内容:
GamePlayer.distinct('user', function(err, results){
});
是否有收集方法将查询更改为以下内容:
GamePlayer.distinct('user', function(err, results){
});
我有字段要填充,还有其他一些事情,比如跳过和限制我该怎么做that@DeepakBhattarai我有字段要填充,还有其他一些事情,比如跳过和限制我该怎么做that@DeepakBhattarai我有字段要填充,还有其他一些事情,比如跳过和限制我该怎么做that@DeepakBhattarai我有要填充的字段和其他字段比如跳过和限制我该怎么做that@DeepakBhattarai