I am using Typeform to store value multiple tables in my DB. But after saving my value it's the return Promise { } instead of a value. This is my function. I follow the most similar question link in StackOverflow to understand my problem. But non of that methods is not working for me...I really need your help. Thank you very much.
async create(orderData: CreateOrderDto): Promise<any> {
const orderModel: {
created_date: Date;
status: string;
customer: Customer;
} = {
status: orderData.status,
created_date: orderData.created_date,
customer: orderData.customer,
};
try {
await this.entityManager.transaction(
async (entityManager: EntityManager) => {
const order = await entityManager
.getRepository(Order)
.save(orderModel);
if (order) {
orderData.order_details.map(async (item) => {
await entityManager
.getRepository(OrderHasItem)
.save({
order_id: order.id,
item_id: item.item_id,
unit_price: item.unit_price,
qty: item.qty,
})
.then((item) => {
console.log('item', item);
return item;
});
});
}
},
);
} catch (error) {
console.log(error);
throw new BadRequestException('There is an error');
}
}