123456789101112131415161718192021 |
- import { Low, JSONFile } from "lowdb";
- type IDBData = {
- buildObj: {
- [key: string]: string[];
- };
- };
- // 单例
- export class DB {
- private static _db?: Low<IDBData>;
- public static getDB():Low<IDBData>{
- // 第一次初始化
- if (this._db == undefined) {
- const adapter = new JSONFile<IDBData>("./db.json");
- this._db = new Low(adapter);
- }
-
- return this._db;
- }
- }
|