0
votes

I want to insert multiple records in mysql with loopback4. e.g. I have a table called Orders I want to insert an entry in orders table and from that entry I want to find order_id and from that order_id I want to insert multiple products in Order_Products table. How can this be done via loopback4?

1

1 Answers

0
votes

You can use CreateAll ; Example:

const order:Orders = await this.orderRepository.create(oreder);
let products=products.map((pro:any)=>{
return{
    ...pro,
    order_id:order.id
}
})  
const product = await this.productRepository.createAll(products);