Populate components while creating/updating an entry with query engine api

System Information
  • Strapi Version: 4.11.2
  • Database: mySQL
  • Node Version: 18.16.0
  • NPM Version: 9.5.1

Hello, I am using an external API to create some entries on my strapi backend. My collection type uses 2 components and I want to pass data to them.

I am using the query engine API but I cannot populate the components. I have tried it like that:

const entry = await strapi.db.query('api::hotel.hotel').update({
        where: { id: fetchHotel.id },
        populate: true,
        data: {
          Name: name,
          OneTourismo_ID: id,
          Description: description,
          Contact: {
            Telephone: "test"
          slug: slug,
          publishedAt: "2021-12-03T20:08:17.740Z"

and everything works except Contact → Telephone (Contact is my component’s name)

Any help would be appreciated.

Hello @kumorin,

Instead of using
await strapi.db.query(‘api::hotel.hotel’).update({ data })
use this
await strapi.entityService.update(“api::hotel.hotel”, fetchHotel.id, { data });

The service method is useful while storing data into components.

Hope this helps :slight_smile: