我的city
架构看起来像这样:
...
name: String,
reviews: [{
user: String,
text: String
}],
...
我使用
创建一个新的city
var city = new City({
name: "London",
reviews: {user: "test user", text: "This is the review"}
});
city.save(function(err){
//check for err
//do stuff
});
但我收到此错误:
CastError:施放到数组失败的值" [object Object]"
我做错了什么?
答案 0 :(得分:0)
您正在评论中传递一个对象来代替数组。将其作为
传递var city = new City({
name: "London",
reviews: [{user: "test user", text: "This is the review"}]
});