Strapi 4: Update single component on User object

Hi,

I’m using Strapi’s Database Query API to update users, but are having problems with updating the attached single component profile, which is attached to the User model.

    const updated_user = await strapi.db.query("plugin::users-permissions.user").update({
      where: { id: user.id },
      data: {
        confirmed,
        email,
        profile: {
          id: user.profile.id,
          bio: "test"
        },
      },
      populate: ["profile"],
    })

I’m following the docs on components and dynamic zones, but can’t use the entity service withe the user-permissions plugin. Perhaps the Database Query API doesn’t work in the same way?

Seems like this should be straightforward – what am I doing wrong?

For anybody wondering this doesn’t work with strapi.db.query. You’ll have to use the Entity Service API like this:

const profile = await strapi.entityService.update("plugin::users-permissions.user", user.id, {
  data: {
    confirmed,
    email,
    firebase_provider: providers[sign_in_provider],
    profile: {
      id: user.profile.id,
      bio: "test"
    },
  },
  populate: ["profile"],
})