SANE 堆栈如何表示单个模型上的 parent/child 关系
How does the SANE stack represent parent/child relationships on a single model
如何在同一模型上表示 parent/child 关系?
这方面的一个例子是表示文件夹的模型。一个父文件夹可以有多个子文件夹。但是一个子文件夹只能有一个父文件夹。
Ember.js有reflexive relations的概念。我想实施第一个选项。
"... explicitly define the other side, and set the explicit inverse
accordingly ..."
我将如何在 SANE 堆栈的 sails.js 侧进行设置?
我不确定您需要在客户端站点上进行哪些调整,但是我很确定在 Sails 端执行此操作的唯一方法是设置第二个引用相同模型的模型 table.
这将允许您拥有 table 个自身具有一对多关系的项目。
stuffA.js
module.exports = {
table:'stuff',
attributes: {
otherStuff : {
model: 'modelB'
}
}
}
stuffB.js
module.exports = {
table:'stuff',
otherstuff: {
collection : 'stuffA',
via: 'otherstuff'
}
}
我知道这可能无法回答您的问题,因为您问过如何在单个 模型 上执行此操作,但如果您指的是单个 Collection / Table .
如何在同一模型上表示 parent/child 关系?
这方面的一个例子是表示文件夹的模型。一个父文件夹可以有多个子文件夹。但是一个子文件夹只能有一个父文件夹。
Ember.js有reflexive relations的概念。我想实施第一个选项。
"... explicitly define the other side, and set the explicit inverse accordingly ..."
我将如何在 SANE 堆栈的 sails.js 侧进行设置?
我不确定您需要在客户端站点上进行哪些调整,但是我很确定在 Sails 端执行此操作的唯一方法是设置第二个引用相同模型的模型 table.
这将允许您拥有 table 个自身具有一对多关系的项目。
stuffA.js
module.exports = {
table:'stuff',
attributes: {
otherStuff : {
model: 'modelB'
}
}
}
stuffB.js
module.exports = {
table:'stuff',
otherstuff: {
collection : 'stuffA',
via: 'otherstuff'
}
}
我知道这可能无法回答您的问题,因为您问过如何在单个 模型 上执行此操作,但如果您指的是单个 Collection / Table .