0
我有2种模式:猫鼬:找到所有参考文件
var pollSchema = new mongoose.Schema({
title: String,
created: {
type: Date, default: Date.now
},
options: [{
label: String,
count: {
type: Number, default: 0
},
backgroundColor: {
type: String, default: '#fff'
}
}],
author:{
id:{
type: mongoose.Schema.Types.ObjectId,
ref: "User"
},
username: String
}
});
var userSchema = new Schema({
username: {type: String, unique:true},
email: {type: String, unique:true, lowercase: true},
password: String
});
现在每个调查都会存储它的作者的数据。 问题:
- 如何重新设计我的模式 - 所以我将能够找到属于特定用户的所有投票?
- 或者我应该让模式保持不变并找到另一种方法?