2023.02.23.3
This commit is contained in:
parent
e74533f1f2
commit
387ab7e582
2 changed files with 7 additions and 4 deletions
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "mit.db",
|
||||
"version": "2023.02.23.2",
|
||||
"version": "2023.02.23.3",
|
||||
"description": "An easy and quick database",
|
||||
"main": "build/index.js",
|
||||
"types": "build/index.d.ts",
|
||||
|
|
|
@ -4,6 +4,8 @@ import * as fs from 'fs';
|
|||
const writeDB = promisify(fs.writeFile);
|
||||
|
||||
class MitDB {
|
||||
readonly db;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @param filename If not set, MapDB will only use internal memory
|
||||
|
@ -12,15 +14,16 @@ class MitDB {
|
|||
* @param options.dirname where to put the database?
|
||||
*/
|
||||
constructor(fn: string, options?: { dirname: string }) {
|
||||
let dirname;
|
||||
if (options && options.dirname) {
|
||||
this.dirname = options.dirname;
|
||||
dirname = options.dirname;
|
||||
} else {
|
||||
this.dirname = 'data';
|
||||
dirname = 'data';
|
||||
}
|
||||
|
||||
if (!fs.existsSync(dirname)) fs.mkdirSync(dirname);
|
||||
|
||||
this.db = `./${dirname}/${filename}`
|
||||
this.db = `./${dirname}/${fn}`
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue