【发布时间】:2017-07-11 16:35:37
【问题描述】:
谁能解释一下为什么将数组添加到我的数据库的一种方法有效而另一种无效。真的不知道有什么区别。我正在使用aldeed/node-simple-schema 和collection2。
例如:Schema
'topFiveSkills': { type: Array, optional: true },
'topFiveSkills.$': { type: String, optional: true }
示例:“工作示例”
topFiveSkills = ["One", "Two", "Three"]
this.state.topFiveSkills.map((skill) => {
ProfileCandidate.update(this.state.profileCandidateCollectionId, {
$push: { 'topFiveSkills': skill }
});
})
示例:“不起作用”
topFiveSkills = ["One", "Two", "Three"]
ProfileCandidate.update(this.state.profileCandidateCollectionId, {
$push: { 'topFiveSkills': { $each: [topFiveSkills] }}
});
【问题讨论】:
标签: meteor simple-schema meteor-collection2