I have a table called companies, and the other is companies_posts, where company_posts.company_idis the foreign key forcompanies.id
Suppose I got the following json:
{
"name" : "Teste",
"username" : "teste1",
"password" : "teste1",
"email" : "teste2@teste",
"photo" : "teste",
"description" : "teste",
"company_posts" : [
{"text" : "oi"},
{"text" : "olá"}
]
}
Is there a way in bookshelf.jsto insert it right away? I guess like a mongodb. Or do I need insert companyto receive lastInsertId, and then inserteach company_postsimmediately after?
Thank.
Edit: (By the way, I just learned selectusing withRelatedand hasMany. Now I have to find out how insert/ update)
source
share