我有一张名为companies
的表和另一张名为companies_posts
的表,其中company_posts.company_id
是对companies.id
的外键引用。
假设我有以下json
:
{
"name" : "Teste",
"username" : "teste1",
"password" : "teste1",
"email" : "teste2@teste",
"photo" : "teste",
"description" : "teste",
"company_posts" : [
{"text" : "oi"},
{"text" : "olá"}
]
}
在
bookshelf.js
中是否有一次性插入的方法?就像mongodb一样。还是我需要先插入公司
,获得lastInsertId
,然后在其后插入每个公司文章
?谢谢。
编辑:(顺便说一下,我刚学会使用
withRelated
和hasMany
进行选择
。现在我必须学习如何插入/更新
)