How add new component entry to an existing entry?

System Information
  • Strapi Version: 3.5.0
  • Database: MongoDB

Hello everyone! :slight_smile:
I want to add a new entry (component) to an existing entry, whats request should i do?

I tried this, but got the error:

        await strapi.query('chat').findOne({id: ctx.request.body.datausersupportid}).create({
            chat: [
                {
                    __component: 'chat',
                    message: ctx.request.body.message,
                }
            ],
        })

error TypeError: strapi.query(...).findOne(...).create is not a function

Thanks a lot

You can use update directly:

strapi.query('chat').update({id: ctx.request.body.datausersupportid}, {data})

And maybe itโ€™s more safe to use strapi services instead of query directly :wink: