Skip to content

介绍

存储模块 - sqlite数据库。

使用方法

javascript
const { SqliteStorage } = require('ee-core/storage');

API列表

sqlite数据库

javascript
const dbFile = path.join(getDataDir(), "db", this.dbname);
const sqliteOptions = {
  timeout: 6000,
  verbose: console.log
}
this.storage = new SqliteStorage(dbFile, sqliteOptions);
this.db = this.storage.db;

storage.db

javascript
# 插入数据    
const insert = this.db.prepare(`INSERT INTO ${table} (name, age) VALUES (@name, @age)`);
insert.run(data);

storage.name

db名称

storage.mode

路径模式:":memory:", "absolute", "relative", "onlyName"

storage.getDbDir

获取 db 文件目录

storage.fileName

格式化后的db名称