/* eslint-disable no-unused-vars */ import moment from 'moment' import '../../config' import { prismaClient as prisma } from '../../prismaClient' import { sendPost } from '../../queues' prisma.post .findMany({ where: { AND: [{ postSentAt: { equals: null } }, { sendPostAt: { equals: null } }], createdAt: { gte: moment().subtract(3, 'days').toDate() }, }, select: { id: true, title: true }, take: 10, }) .then(async (posts) => { console.log('posts.length', posts.length) for await (const post of posts) { console.log(`Sending post id: "${post.id}" with title "${post.title}"`) await sendPost(post.id) } }) .catch(console.error)