如果我有多对多的关系,那么用它的sync
方法更新关系是非常容易的.
但是我会用什么来同步一对多的关系呢?
posts
:id, name
links
:id, name, post_id
在这里,每个Post
可以有多个Link
s.
我想将与数据库中特定帖子相关联的链接与输入的链接集合(例如,从我可以添加,删除和修改链接的CRUD表单)同步.
应删除数据库中不存在于我的输入集合中的链接.应更新数据库和输入中存在的链接以反映输入,并且仅在我的输入中存在的链接应作为新记录添加到数据库中.
总结所需的行为:
我想要一个经过计算的属性名称。我看到您可以在ES6中使用它。但是它应该与IOS Webview兼容。所以我不能使用ES6。而且,如果这会使某人更容易,则计算出的名称在循环内也将始终相同。
有任何想法吗?
var today = moment().format('DD.MM.YY');
for (var i = 0; i < 5; i++) {
initialData.push(
{
dates: {
"01.01.01": false
// instead of 01.01.01 i would like to have the value of today as the key
}
}
)
}
Run Code Online (Sandbox Code Playgroud) 我该怎么做这个数组:
array(2) {
[0]=>
array(1) {
["plz"]=>
string(4) "4460"
}
[1]=>
array(1) {
["plz"]=>
string(4) "4000"
}
}
Run Code Online (Sandbox Code Playgroud)
变成这样的东西只需要一个数组键中的值无关紧要:
array(2) {
[0]=>
string(4) "4460"
[1]=>
string(4) "4000"
}
Run Code Online (Sandbox Code Playgroud)
是否有辅助功能或可以帮助的东西?