KeystoneJS 关系字段不保存空值
KeystoneJS Relationship field not saving empty value
KeystoneJS 中的常规 Relationship
字段(本例中为 categories
):
Post.add({
author: { type: Types.Relationship, ref: 'User' },
categories: { type: Types.Relationship, ref: 'PostCategory', many: true }
});
最初它是空的,但是当我向它添加一些值时,保存它然后清除它(这样该字段再次为空),保存这个模型不会更新 categories
.
console.log(this.categories)
in Post.schema.pre('save', ...
显示 this.categories
有以前的值,而 它应该是空的 .
对这种行为有什么想法吗?
KeystoneJS 中的常规 Relationship
字段(本例中为 categories
):
Post.add({
author: { type: Types.Relationship, ref: 'User' },
categories: { type: Types.Relationship, ref: 'PostCategory', many: true }
});
最初它是空的,但是当我向它添加一些值时,保存它然后清除它(这样该字段再次为空),保存这个模型不会更新 categories
.
console.log(this.categories)
in Post.schema.pre('save', ...
显示 this.categories
有以前的值,而 它应该是空的 .
对这种行为有什么想法吗?