diff --git a/package.json b/package.json index 3544200..9b71b5b 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/index.ts b/src/index.ts index a504a86..cbc0ae6 100644 --- a/src/index.ts +++ b/src/index.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}` } /**