Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Database configuration
- const dbName = 'keyval-store';
- const dbVersion = 1;
- const storeName = 'keyval';
- // Open a connection to the IndexedDB
- let request = indexedDB.open(dbName, dbVersion);
- request.onerror = function(event) {
- console.error('Error opening IndexedDB', event);
- };
- request.onsuccess = function(event) {
- let db = event.target.result;
- // Get a transaction and object store reference
- const transaction = db.transaction([storeName], 'readwrite');
- const objectStore = transaction.objectStore(storeName);
- // Read the "pizzax::base" key
- const getKeyRequest = objectStore.get('pizzax::base');
- getKeyRequest.onsuccess = function(event) {
- const existingData = event.target.result || {};
- // Update the data with the new property
- existingData['nsfw'] = 'ignore';
- existingData['highlightSensitiveMedia'] = false;
- existingData['loadRawImages'] = true;
- // Put the updated data back into the store
- const putRequest = objectStore.put(existingData, 'pizzax::base');
- putRequest.onsuccess = function() {
- console.log('Data updated successfully');
- };
- putRequest.onerror = function(event) {
- console.error('Error updating data', event);
- };
- };
- getKeyRequest.onerror = function(event) {
- console.error('Error reading data', event);
- };
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement