MCPcopy
hub / github.com/ZToolsCenter/ZTools / dbPut

Method dbPut

src/main/api/shared/database.ts:393–414  ·  view source on GitHub ↗

* 内部使用的数据库辅助方法 * 用于主进程内部直接操作 ZTOOLS 命名空间的数据

(key: string, data: any)

Source from the content-addressed store, hash-verified

391 * 用于主进程内部直接操作 ZTOOLS 命名空间的数据
392 */
393 public dbPut(key: string, data: any): any {
394 try {
395 const docId = `ZTOOLS/${key}`
396
397 // 将数据包装到 data 字段中,以正确支持数组和对象
398 const doc: any = {
399 _id: docId,
400 data: data
401 }
402
403 // 获取现有文档以保留 _rev
404 const existing = lmdbInstance.get(docId)
405 if (existing) {
406 doc._rev = existing._rev
407 }
408
409 return lmdbInstance.put(doc)
410 } catch (error) {
411 console.error('[Database] dbPut 失败:', key, error)
412 throw error
413 }
414 }
415
416 public dbGet(key: string): any {
417 try {

Callers 15

setupIPCMethod · 0.95
setupIPCMethod · 0.45
handleClearHistoryFunction · 0.45
scanAndCacheAppsMethod · 0.45
addToHistoryMethod · 0.45
updateUsageStatsMethod · 0.45
removeFromHistoryMethod · 0.45
pinAppMethod · 0.45
unpinAppMethod · 0.45
updatePinnedOrderMethod · 0.45
saveLastMatchStateMethod · 0.45

Calls 2

getMethod · 0.65
putMethod · 0.45

Tested by

no test coverage detected