【发布时间】:2015-05-20 13:26:39
【问题描述】:
我有一个名为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 一样。或者我需要insert company,得到lastInsertId,然后是insert每个company_posts?
谢谢。
编辑:(顺便说一句,我刚刚学会了如何使用withRelated 和hasMany 来select。现在我必须学习如何insert / update)
【问题讨论】:
标签: mysql node.js bookshelf.js