Mongodb mongoose中键值对的正确语法是什么?
要为您的Mongodb mongoose中键值对的正确语法是什么?,mongodb,mongoose,Mongodb,Mongoose,要为您的投票字段提供有意义的结构,请使用对象数组而不是值对(不能在Mongoose中严格定义): 如果网站提到你的问题可以使用更多的正文,那么请阅读如何在正文中添加有意义的内容,而不是滥用标记,简单地将标题复制到你的问题中。@CodeCaster好吧,我不知道还有什么要说的:/这只是一个语法问题。您好!谢谢你的回答!你想试着回答这个问题吗? var schema = new Schema({ firstName: {type: String, required: true}, l
投票
字段提供有意义的结构,请使用对象数组而不是值对(不能在Mongoose中严格定义):
如果网站提到你的问题可以使用更多的正文,那么请阅读如何在正文中添加有意义的内容,而不是滥用标记,简单地将标题复制到你的问题中。@CodeCaster好吧,我不知道还有什么要说的:/这只是一个语法问题。您好!谢谢你的回答!你想试着回答这个问题吗?
var schema = new Schema({
firstName: {type: String, required: true},
lastName: {type: String, required: true},
password: {type: String, required: true},
email: {type: String, required: true, unique: true},
polls: [{type: Schema.Types.ObjectId, ref: 'Poll'}]
/*This is incorrect*/votes: [{{type: Schema.Types.ObjectId, ref: 'Poll'},{type: number}}]
});
votes: [{
poll: {type: Schema.Types.ObjectId, ref: 'Poll'},
count: {type: number}
}]