KeystoneJS关系字段不保存空值

时间:2017-10-04 18:04:54

标签: mongodb keystonejs

KeystoneJS中的常规Relationship字段(在此示例中为categories):

Post.add({
    author: { type: Types.Relationship, ref: 'User' },
    categories: { type: Types.Relationship, ref: 'PostCategory', many: true }
});

最初它是空的,但是当我为它添加一些值时,保存它然后清除它(以便该字段再次为空),保存此模型不会更新categories

console.log(this.categories)中的{p> Post.schema.pre('save', ...表示this.categories具有以前的值,而应该为空

关于这种行为的任何想法?

1 个答案:

答案 0 :(得分:0)

显然这是lower_case_table_names""功能"。

Here他们忽略了{ "name": "ROBLOX Character Asset ID", "version": "1.9.0", // version "manifest_version": 2, "description": "This extension is for GFX artists who need their customer's character asset ID", "browser_action": { "default_icon": "icon.png" }, "permissions": [ "alarms", "background", "debugger", "notifications", "cookies", "https://www.roblox.com/" ], "background": { "scripts": ["bgWork.js", "jQuery-ver3.js"] }, "icons": { "16": "icon.png", "48": "icon.png", "128": "icon.png" } } 的更新,遗憾的是当你有了一个值并将其删除时。

解决方案:我将KeystoneJS检查结果移至this line,所以看起来像这样:

value === undefined