Search⌘ K
AI Features

Using Cursor to Update and Delete Data of the Object Store

Explore how to use IndexedDB cursors to update and delete records within an object store. Learn the syntax and steps to modify data while iterating through entries, including handling success and error events. This lesson helps you understand practical methods to manipulate data dynamically in client-side storage.

We can alter or remove the data while iterating through data with a cursor. This is done using the update() method for changes and the delete() method for deletions.

The update() method

The update() method will commit the value provided into the object store.

Syntax

cursorObject.update(new_value)
Syntax for the update() method

This method takes the new_value to be updated as an argument and returns an IDBRequest object as a return value. We can add the success and error event listeners to the returned object to listen for the state of the update operation. ...