23 lines
502 B
JavaScript
23 lines
502 B
JavaScript
import serialize from '@/api/resolvers/serial.js'
|
|
|
|
export async function auction ({ models }) {
|
|
// get all items we need to check
|
|
const items = await models.item.findMany(
|
|
{
|
|
where: {
|
|
maxBid: {
|
|
not: null
|
|
},
|
|
status: {
|
|
not: 'STOPPED'
|
|
}
|
|
}
|
|
}
|
|
)
|
|
|
|
// for each item, run serialized auction function
|
|
items.forEach(async item => {
|
|
await serialize(models.$executeRaw`SELECT run_auction(${item.id}::INTEGER)`, { models })
|
|
})
|
|
}
|