Link to home
Start Free TrialLog in
Avatar of Mac Cruz
Mac Cruz

asked on

How to update IndexedDB

Hi experts, I want to update my IndexedDb that the value of msales be updated and be added to 30.00 to become 250.00 in result and the value of created will remain.

My IndexdDB
key = 1975 value = {msales: "220.00", created: "11-18-2019"}

Js
function gsaleslocal(){
	var sales = "30.00"

	var transaction = db.transaction(["gsales"],"readwrite");
	var store = transaction.objectStore("gsales");

	var mytrx = {
	    msales: sales,
	};

	var request = store.put(mytrx,1975);
	
	request.onerror = function(e) {
			console.log("Error", e.target.error.name);
	}
	request.onsuccess = function(e) {
			console.log("Successfully added");
	}
};

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mac Cruz
Mac Cruz

ASKER

Thank you leakim971, your solution lead me to solve the problem..
you welcome, have a nice day