Hi ,
I want to track the changes done by browser in IndexedDB database i.e.(database created , insertions, updates , deletion in objectstore ) and save those changes somewhere , How can I do it ?
I am trying to do it using proxy using following code but i am not getting it .onsuccess , onerror or any other event.
Code:
const handler = {
apply: function apply(target, thisArg, argumentsList) {
console.log("****************** argumentsList = ", argumentsList);
const result = target.apply(thisArg, argumentsList);
console.log("*********************** RETURNNING RESULT = *****************", result);
result.onblocked = (event) => {
console.log("*********************** INSIDE ONBLOCKED ***************");
};
result.onupgradeneeded = (event) => {
console.log("*********************** INSIDE ONUPGRADENEEDED *****************");
};
result.onsuccess = function(event) {
console.log("*********************** INSIDE ONSUCCESS *****************");
const db = event.target.result;
console.log(`Database opened successfully: ${db.name}`);
// Log schema (object stores) or perform other actions
};
result.onerror = function(event) {
console.error("******************** Error opening database:", event.target.error);
};
return result;
}
};
if (window.indexedDB) {
window.indexedDB.open = new Proxy(window.indexedDB.open, handler);
}