本文整理汇总了TypeScript中leveldown.default方法的典型用法代码示例。如果您正苦于以下问题:TypeScript leveldown.default方法的具体用法?TypeScript leveldown.default怎么用?TypeScript leveldown.default使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类leveldown
的用法示例。
在下文中一共展示了leveldown.default方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: leveldown
import * as leveldown from "leveldown";
let db = leveldown("db1");
db.open((err) => {});
db.open({createIfMissing: true}, (err) => {});
db.put("key", "value", (err) => {});
db.put(Buffer.from("key"), Buffer.from("value"), (err) => {});
db.put("key", "value", {sync: true}, (err) => {});
db.get("key", {asBuffer: false}, (error, val) => {
console.log(val.toUpperCase());
});
db.get("key", {fillCache: true}, (error, val) => {
console.log(val.readUInt32BE(0));
});
db.get("key", (error, val) => {
console.log(val.readUInt32BE(0));
});
db.del("key");
db.del("key", (error) => {});
db.del("key", {sync: true}, (error) => {});
db.batch([{
type: "put", key: "k", value: "v"
}, {
type: "del", key: "k"
}], (error) => {});
示例2: constructor
constructor() {
super();
this.db = levelup(leveldown("./mydb"));
}
示例3: leveldown
import * as leveldown from "leveldown";
const db = leveldown("db1");
db.open((err) => {});
db.open({createIfMissing: true}, (err) => {});
db.put("key", "value", (err) => {});
db.put(Buffer.from("key"), Buffer.from("value"), (err) => {});
db.put("key", "value", {sync: true}, (err) => {});
db.get("key", {asBuffer: false}, (error, val) => {
console.log(val.toUpperCase());
});
db.get("key", {fillCache: true}, (error, val) => {
console.log(val.readUInt32BE(0));
});
db.get("key", (error, val) => {
console.log(val.readUInt32BE(0));
});
db.del("key");
db.del("key", (error) => {});
db.del("key", {sync: true}, (error) => {});
db.batch([{
type: "put", key: "k", value: "v"
}, {
type: "del", key: "k"
}], (error) => {});
示例4: constructor
constructor(storePath: string) {
this.db = levelup(leveldown(storePath));
this._cachedGet = cacheLevelDBGet(this.db);
}