当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript idb.DB类代码示例

本文整理汇总了TypeScript中idb.DB的典型用法代码示例。如果您正苦于以下问题:TypeScript DB类的具体用法?TypeScript DB怎么用?TypeScript DB使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DB类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: saveMetadata

 async saveMetadata(name: string, value: Uint8Array | undefined): Promise<void> {
   const trans = this.db.transaction(["metadata"], "readwrite");
   const store = trans.objectStore("metadata");
   if(value){
     await store.put({name, value});
   }else{
     await store.delete(name);
   }
 }
开发者ID:strangesast,项目名称:es-git,代码行数:9,代码来源:index.ts

示例2: setRef

 async setRef(ref : string, hash : Hash | undefined) : Promise<void> {
   const trans = this.db.transaction(["refs"], "readwrite");
   const store = trans.objectStore("refs");
   if(hash === undefined){
     await store.delete(ref);
   }else{
     const entry = { path: ref, hash: hash };
     await store.put(entry);
   }
 }
开发者ID:strangesast,项目名称:es-git,代码行数:10,代码来源:index.ts

示例3: loadMetadata

 async loadMetadata(name: string): Promise<Uint8Array | undefined> {
   const trans = this.db.transaction(["metadata"], "readonly");
   const store = trans.objectStore("metadata");
   const result = await store.get(name).catch(N => undefined);
   return result ? result.value as Uint8Array : undefined;
 }
开发者ID:strangesast,项目名称:es-git,代码行数:6,代码来源:index.ts

示例4: hasObject

 async hasObject(hash: string): Promise<boolean> {
   const trans = this.db.transaction(["objects"], "readonly");
   const store = trans.objectStore("objects");
   return await store.getKey(hash).then(key => key !== undefined, N => false);
 }
开发者ID:strangesast,项目名称:es-git,代码行数:5,代码来源:index.ts

示例5: getRef

 async getRef(ref : string) : Promise<Hash | undefined> {
   const trans = this.db.transaction(["refs"], "readonly");
   const store = trans.objectStore("refs");
   const result = await store.get(ref).catch(N => undefined);
   return result ? result.hash as Hash : undefined;
 }
开发者ID:strangesast,项目名称:es-git,代码行数:6,代码来源:index.ts

示例6: listRefs

 async listRefs() : Promise<Hash[]> {
   const trans = this.db.transaction(["refs"], "readonly");
   const store = trans.objectStore("refs");
   return await store.getAllKeys() as Hash[];
 }
开发者ID:strangesast,项目名称:es-git,代码行数:5,代码来源:index.ts

示例7: loadRaw

 async loadRaw(hash : Hash) : Promise<Uint8Array | undefined> {
   const trans = this.db.transaction(["objects"], "readonly");
   const store = trans.objectStore("objects");
   const result = await store.get(hash).catch(N => undefined);
   return result ? result.raw as Uint8Array : undefined;
 }
开发者ID:strangesast,项目名称:es-git,代码行数:6,代码来源:index.ts

示例8: saveRaw

 async saveRaw(hash : Hash, raw : Uint8Array) : Promise<void> {
   const trans = this.db.transaction(["objects"], "readwrite");
   const store = trans.objectStore("objects");
   await store.put({hash, raw});
 }
开发者ID:strangesast,项目名称:es-git,代码行数:5,代码来源:index.ts


注:本文中的idb.DB类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。