Extracted function types
Hello! I extracted a function to map a query. But I can't find the correct types.
I'm looking for the type
I'm looking for the type
orderorder, orderLineorderLine, ctxctx and qq.orderorder and orderLineorderLine are raw records in the database.const transformOrderForClient = async (order: any, ctx: any) => {
const orderLines = await ctx.db
.query('order_lines')
.filter((q: any) => q.eq(q.field('orderId'), order._id))
.collect()
const mappedOrderLines = await Promise.all(
orderLines.map(async (orderLine: any) => {
const product = await ctx.db.get(orderLine.productId)
console.log('product', orderLine)
return {
// ...
}
}),
)
const grandTotalAmount = orderLines.reduce((acc: any, orderLine: any) => {
return acc + orderLine?.price * orderLine?.quantity
}, 0)
const grandTotalQuantity = orderLines.reduce((acc: any, orderLine: any) => {
return acc + orderLine.quantity
}, 0)
return {
// ...
}
}const transformOrderForClient = async (order: any, ctx: any) => {
const orderLines = await ctx.db
.query('order_lines')
.filter((q: any) => q.eq(q.field('orderId'), order._id))
.collect()
const mappedOrderLines = await Promise.all(
orderLines.map(async (orderLine: any) => {
const product = await ctx.db.get(orderLine.productId)
console.log('product', orderLine)
return {
// ...
}
}),
)
const grandTotalAmount = orderLines.reduce((acc: any, orderLine: any) => {
return acc + orderLine?.price * orderLine?.quantity
}, 0)
const grandTotalQuantity = orderLines.reduce((acc: any, orderLine: any) => {
return acc + orderLine.quantity
}, 0)
return {
// ...
}
}