How to query user(s)? v4

System Information
  • Strapi Version: 4.1.0
  • Database: MYSQL

How can we query user(s) with the query engine?

I expected something like this:

const entry = await strapi.db.query('api::user.user').findOne({
  where: { email: email }
})

But that ain’t working. It is also not stated in the docs.

How could one query a user?

TIA

1 Like
const entry = await strapi.db.query('plugin::users-permissions.user').findOne({
  where: { email: email }
})
7 Likes

Aha. I understand now. Thank you very much! :ok_hand::sunglasses:

1 Like

Is there any way you could point me to the part of the docs where I can find more on this. Like for example how to update the user up_user data

You can use this to update. Check out the Entity Service and Query Engine sections of the docs

    let updatedUser = await strapi.query("plugin::users-permissions.user").update({
      where: { id: newUser.id },
    });
1 Like