本文整理匯總了TypeScript中levelup類的典型用法代碼示例。如果您正苦於以下問題:TypeScript levelup類的具體用法?TypeScript levelup怎麽用?TypeScript levelup使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了levelup類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: constructor
constructor() {
super();
this.db = levelup(leveldown("./mydb"));
}
示例2: encode
buffer: boolean;
type: string;
}
interface StringEncoding {
encode(val: any): string;
decode(val: string): any;
buffer: boolean;
type: string;
}
declare const bufferEncoding: BufferEncoding;
declare const stringEncoding: StringEncoding;
var db1 = levelup("db1", {
keyEncoding: bufferEncoding,
valueEncoding: bufferEncoding
});
var db2 = levelup("db2", {
keyEncoding: stringEncoding,
valueEncoding: stringEncoding
});
var db = levelup('./mydb')
db.open();
db.close();
db.open((error)=> {
});
db.close((error)=> {
示例3: constructor
constructor(storePath: string) {
this.db = levelup(leveldown(storePath));
this._cachedGet = cacheLevelDBGet(this.db);
}
示例4: constructor
constructor(dbPath?: string) {
this._db = Sublevel(LevelUp(dbPath || './', {
db: dbPath ? leveldown : require('memdown'),
valueEncoding: 'json',
//errorIfExists: false
}));
this.users = new Bucket<string,User>('user', u => u.name, this._db);
}