0

I am using Indexdb in my project. I am performing an IndexDB operation using JSstore. I am able to perform all operations. But am unable to bulk update. can anyone help me with how can I update bulk updates using IndexDB?

I am able to update a single update like below

updateEmployeeById(id, updateData) {
        return this.connection.update({ in: this.M_EMP,
            set: updateData,
            where: {
                id: id
            }
        })
}

I am trying to update data using looping. But not able to update. My data and method is below

var arr = [
        {
            "age": 22,
            "company": "ACLIMdfsdfsdfdsfA",
            "email": "[email protected]",
            "gender": "male",
            "id": 1
        },
        {
            "age": 22,
            "company": "sssss",
            "email": "[email protected]",
            "gender": "malde",
            "id": 2
        }
    ]
     bulkUpdateEmployee(dataArr){
            dataArr.forEach((element, index) => {
               this.connection.update({ in: this.M_EMP,
                    set: {company: element.company},
                    where: {
                        id: element.id
                    }
                })
            });
        }
2
  • 1
    code looks good. Only problem i see is you are not awaiting the update. Also update returns no of data updated, check that value. Commented Jun 22, 2021 at 4:20
  • Can you please suggest me? how can I fix this? Thanks Commented Jun 22, 2021 at 4:55

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.