2023.02.23.3

This commit is contained in:
Killer Boss Original 2023-02-23 12:15:27 +01:00 committed by GitHub
parent e74533f1f2
commit 387ab7e582
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 4 deletions

View file

@ -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",

View file

@ -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}`
}
/**