Invoice-Model:
attributes: {
number: {
type: 'integer'
}
lines: {
collection: 'line',
via: 'invoice'
}
}
Line-Model:
attributes: {
name: {
type: 'integer'
}
invoice: {
model: 'invoice'
}
}
As you can see these models have a One-To-Many relationship. Everything is working fine.
But now I want to create a new Invoice and new Lines with the Blueprint API that are associated.
The documentation says you can create a new record and add it to an existing one with this schema: POST /:model/:id/:association/:fk
But it does not state if it is possible to create two records at the same time and associate them.
More details: I've got an invoice and in this invoice you can add lines with products, their quantity and other stuff. Now when the user clicks on save, I need to create a new invoice and the new lines and associate them somehow.
Should I create a custom Controller Action for this, or am I overthinking this and I should do this whole thing completely different?