I have 2 models called users
and books
with one to many associations. My schema looks like
1. model user.js
module.exports = {
attributes: {
userName: {
type: 'string'
},
books: {
type: 'ref',
columnType: 'book',
via: 'userBooks'
}
book.js model
attributes: {
bookName: {
type: 'string'
},
userBooks: {
model: 'user'
}
A user may contains any number of books, I am adding fields of books under user create form, on clicking submit button I need to create records in both user table and book table. Can anyone help me how we can handle the same in controller. Thanks in advance.