Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

358
Views
STRAPI v4 how to refactor schedule post publish from v3 to v4

I try to recreate the schedule posts from STRAPI v3 for strapi v4

but I get stuck at the update function, am I missing a filter, some new formating, or params?

config/server.js

schedule = require('./controllers/scedulePosts')

module.exports = ({ env }) => ({
  host: env('HOST', '0.0.0.0'),
  port: env.int('PORT', 1337),
  cron :{
    enabled: true,
    tasks: {
      '*/10 * * * * *': ({ strapi }) => {
        schedule.schedulePublishArticles(strapi)
      }
    }
  }
});

/config/controllers/schedulePosts.js

module.exports = {
  schedulePublishArticles: async (strapi) => {
    try {
      let draftArticleToPublish = await strapi.api.article.services.article.find(
        { publicationState: 'preview',
          filters: {
            publishedAt: null,
            publishOn: new Date(new Date().setSeconds(0, 0))

          }
        }
      )

       // update publishedAt of articles
      await Promise.all(draftArticleToPublish.results.map(article => {
        return strapi.api.article.services.article.update(
          {id: article.id},
          {publishedAt: new Date()}
        )
      }));

    } catch (e) {
      console.log(e.message)
    }
  }
}

when the update() functions is called with {id = "int"} it trows this error: "Undefined attribute level operator id"

am I missing some filtering or params structure in update? or is this some kind of bug I V4

thanks

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!