【发布时间】:2017-05-13 11:15:23
【问题描述】:
我有 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
});
现在每个民意调查都将存储其作者的数据。 问题:
- 如何重新设计我的架构 - 这样我才能找到属于特定用户的所有民意调查?
- 还是应该让架构保持不变并寻找其他方法?
【问题讨论】:
标签: node.js mongodb mongoose mongoose-schema