cron-tasks.ts 531 B

12345678910111213141516171819
  1. module.exports = {
  2. checkPublish: {
  3. task: async ({ strapi }) => {
  4. const now = new Date();
  5. const entries = await strapi.documents('api::test-txt.test-txt').findMany({
  6. filters: { publish_at: { $lte: now }, publishedAt: null },
  7. status: 'draft',
  8. });
  9. for (const entry of entries) {
  10. await strapi.documents('api::test-txt.test-txt').publish({
  11. documentId: entry.documentId,
  12. });
  13. }
  14. },
  15. options: {
  16. rule: '* * * * *', // Runs every minute
  17. },
  18. },
  19. };