How to insert into MySQL database and Elastic search same time

Hi this is my first question in this forum. I am new to elastic search. :roll_eyes:

I have an express.js project. ORM is sequlize.js

I have three tables.

  1. Category

  2. Item

  3. City

I have search bar in mobile app where users can search category, item or a city.
So what I did in my category.controller.js file

async function create(req, res, next) {
    const transaction = await db.sequelize.transaction();
    try {

        const data = await db[model_name].create(req.body, {
        await client.create({
            index: 'live_search_index',
            type: 'default',
            id: `cat ${}`,
            body: {
                title: `${}`,
                my_type: `${req.body.my_type}`,
                my_status: true
        await transaction.commit();

    } catch (error) {
        console.log("ERR", error);
        await transaction.rollback();


But I have 3 controllers and each controller I need to alter 3 functions (create, update, enableDisable). So a lot of work and painful.

There might be a smart way to do this.
You install a plugin and all the CRUD operations of a certain table will be automatically sync to elastic search so that no pain.

Is there a way to do so?
or else do I need to continue in this way? :cold_face:

Any help!
Thanks in advanced.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.