Cron error can't find id in where filter

System Information
  • Strapi Version: 3.5.1
  • Operating System:
  • Database: SQLlite
  • Node Version: 12.8.4
  • NPM Version:
  • Yarn Version:


Trying to add a cron task to automatically expire user accounts once the user reaches 30 years old.

I’m able to query the db and find the users but unable to update I get error message:-

(node:5954) UnhandledPromiseRejectionWarning: Error: The value of field: 'id', in your where filter, is undefined.
"*/2 * * * *": async () => {
    //get todays date and work out over 30
    const cutoffMax = new Date();
    cutoffMax.setFullYear(cutoffMax.getFullYear() - 30);
    //get all users who are older than max age
    const youngsters = await strapi.plugins[
      userStatus: "Subscribed",
      dateOfBirth_lt: cutoffMax,
youngsters.forEach(async (member) => {
     await strapi
        .query("user", "users-permissions")
        .update({ id: }, { userStatus: "Expired" });

Have tried using a query directly and using the “Edit” function in the User service. Still the same error message - “The value of field id in your where filter is undefined”

I have logged out the values passed to the service and they are correct. So I don’t really understand why they aren’t being picked up in the query?!

Any help greatly appreciated.