请告诉我我在这里失踪了什么。当我更新对象数组时,我的集合用空数组更新。我使用的是meteor-collection2-core和node-simple-schema。
路径:Method
testArray = [{
"institution": "Swinburn",
"uniqueId": 1501036480813,
"qualification": "Bachelor of Commerce",
"completed": "2017"
}]
ProfileCandidate.update('Ntzj6kE8qZsvSPMEP', {$set: {educationQualifications: testArray}});
路径:Collection
export const ProfileCandidate = new Mongo.Collection('profileCandidate');
const ProfileCandidateSchema = new SimpleSchema({
userId: {
type: String,
regEx: SimpleSchema.RegEx.Id
},
educationQualifications: { type: Array, optional: true },
'educationQualifications.$': { type: Object, optional: true },
'educationQualifications.$.uniqueId': { type: Number, optional: true },
'educationQualifications.$.institution': { type: String, optional: true },
'educationQualifications.$.qualification': { type: String, optional: true },
'educationQualifications.$.completed': { type: String, optional: true }
});
ProfileCandidate.attachSchema(ProfileCandidateSchema);
答案 0 :(得分:0)
在你的方法中,试试这个:
ProfileCandidate.update({userId: 'Ntzj6kE8qZsvSPMEP'}, {$set: {educationQualifications: testArray}});