MCPcopy
hub / github.com/xcanwin/KeepChatGPT / operate

Method operate

KeepChatGPT.user.js:281–316  ·  view source on GitHub ↗
(operation, item)

Source from the content-addressed store, hash-verified

279 }
280
281 async operate(operation, item) {
282 const db = await this.open();
283 return new Promise((resolve, reject) => {
284 const tx = db.transaction(this.storeName, "readwrite");
285 const store = tx.objectStore(this.storeName);
286 let request;
287
288 switch (operation) {
289 case "add":
290 request = store.add(item);
291 break;
292 case "put":
293 request = store.put(item);
294 break;
295 case "delete":
296 request = store.delete(item.id);
297 break;
298 default:
299 db.close();
300 reject("Invalid operation");
301 return;
302 }
303
304 request.onsuccess = function () {
305 resolve(request.result);
306 };
307
308 request.onerror = function () {
309 reject("Error", request.error);
310 };
311
312 tx.oncomplete = function () {
313 db.close();
314 };
315 });
316 }
317
318 async operate_get(id) {
319 const db = await this.open();

Callers 3

addMethod · 0.95
putMethod · 0.95
deleteMethod · 0.95

Calls 4

openMethod · 0.95
addMethod · 0.80
putMethod · 0.80
deleteMethod · 0.80

Tested by

no test coverage detected