我正在使用Sails 1.1.0和sails-disk .
我创建了一个强制性的一对多关系 . Sofa
有 owner
,它与 User
是一对多, Sofa
也有 home
,与 Home
是一对多 . 但是当我 await Home.destroy(homeId);
Home
时,它不会级联并删除 Sofa
. 相反,我得到错误:
PropagationError: Failed to run the "cascade" polyfill. Could not propagate the potential destruction of this home record.
Details:
Cannot wipe the contents of association (`sofas`) because there is one conflicting shame record whose `home` cannot be set to `null`. (That attribute is required.)
This error originated from the fact that the "cascade" polyfill was enabled for this query.
Tip: Try reordering your .destroy() calls.
[?] See https://sailsjs.com/support for more help.
这是我的模型关联:
// api\models\Sofa.js
owner: {
model: 'user',
required: true
},
home: {
model: 'home',
required: true
},
// api\models\User.js
sofas: {
collection: 'sofa',
via: 'owner'
},
// api\models\Home.js
sofas: {
collection: 'sofa',
via: 'home'
},
有没有人有任何想法为什么会这样?