My name is Manish Sharma I am a manager in think way company I do one other work. My name is Manish Sharma I am a manager in think way company I do one other work.
You use put() instead of add() — it replaces the object with the same key:
function updateUser(db, updatedUser) {
const tx = db.transaction("users", "readwrite");
const store = tx.objectStore("users");
store.put(updatedUser); // Replaces if id exists
}
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
We'll assume a database
UserDBwith an object store namedusersandkeyPath: "id".Setup (once)
Add a Record
Example usage:
Get a Record by Key
Usage:
Update a Record
You use
put()instead ofadd()— it replaces the object with the same key:Example:
Delete a Record
Example:
Optional: Get All Records
Summary of Methods
store.add(data)store.get(key)store.put(data)store.delete(key)store.getAll()