System Information
- Strapi Version: v4.*
I’m trying to rewrite the schedule posts from guides to strapi V4
let draftArticleToPublish = await strapi.api.article.services.article.find(
{ publicationState: 'preview',
// next two filter not taken into account in find
published_at_null: true, // so we add another condition here to filter entries that have not been published
publish_at_lt: new Date()
}
)
// update published_at of articles
await Promise.all(draftArticleToPublish.results.map(article => {
console.log('article', article.id)
// filters in update not working
return strapi.api.article.services.article.update(
{ id: article.id },
{ published_at: new Date() }
);
}));
first question: the filters in find() are not working.
-
PublicationState: “preview” is returning draft and published
-
But filters published_at: null is not filtering in the result
-
and the update() functions return error Undefined attribute level operator id