对象数组通过验证但不更新集合

时间:2017-07-19 03:03:24

标签: meteor simple-schema meteor-collection2

我的更新方法是通过简单架构验证测试,但它不会更新我的收藏。我正在更新一个对象数组。

示例:array

var arrayTest = [ 
  { 
    company: 'sdsd',
    uniqueId: 1500431892902,
    title: '',
    description: '',
    startDateMonth: '',
    startDateYear: '',
    endDateMonth: '',
    endDateYear: '',
    isCurrent: false,
    isDisabled: false,
  } 
];

验证:Array

new SimpleSchema({
  company: { type: String, optional: true },
  uniqueId: { type: Number, optional: true },
  title: { type: String, optional: true },
  description: { type: String, optional: true },
  startDateMonth: { type: String, optional: true },
  startDateYear: { type: String, optional: true },
  endDateMonth: { type: String, optional: true },
  endDateYear: { type: String, optional: true },
  isCurrent: { type: Boolean, optional: true },
  isDisabled: { type: Boolean, optional: true }
}).validate(
  arrayTest
);

更新:Collection

ProfileCandidate.update({
  _id: "BoDb4Zztq7n3evTqG"
}, {
  $set: {
    careerHistoryPositions: arrayTest
  }
}, (error, result) => {
  if (error) {
    console.log("error: ", "error");
  }
  if (result) {
    console.log("result", result);
  }
});

更新似乎有效,但架构中没有数据。

0 个答案:

没有答案