0
私は自分のフォームからSimpleSchemaにデータを挿入するのにcollection2を使用しています。 Collection2は挿入前にデータを消去するはずですが、$ pushを使用して配列を挿入すると、データは消去されません。データのないすべてのフィールドには、""
が含まれます。私が知っている限り、$ setを使用してデータを消去することはできません。私は何が欠けていますか?
スニペット:Schema
const ProfileCandidateSchema = new SimpleSchema({
careerHistoryPositions: { type: Array, optional: true },
'careerHistoryPositions.$': { type: Object, optional: true },
'careerHistoryPositions.$.uniqueId': { type: String, optional: true },
'careerHistoryPositions.$.company': {
type: String,
optional: true,
custom: function() {
const shouldBeRequired = this.field('careerHistoryPositions.company').value;
if (!shouldBeRequired) {
// updates
if (this.isSet) {
if (this.operator === '$set' && this.value === null || this.value === '') return SimpleSchema.ErrorTypes.REQUIRED;
}
}
}
}
}, {
clean: {
filter: true,
autoConvert: true,
removeEmptyStrings: true,
trimStrings: true,
getAutoValues: true,
removeNullsFromArrays: true
}
});
スニペット:Update
const updatePosition = this.state.careerHistoryPositions.map((position) => {
ProfileCandidate.update({
_id: this.state.profileCandidateCollectionId
}, {
$push: {
'careerHistoryPositions': {
uniqueId: position.uniqueId,
company: position.company
}
}
});
});
I $ setを大括弧で囲んで 'careerHistoryPositi ons:[] '、他には何もありません。コンソールエラーやサーバーエラーはありません。何か案は? – bp123
検証に失敗したようです。 –
Collection2は、それがサーバー側でもクライアント側でもよいことを示しています。それは方法で実行する必要がありますか? – bp123