@ix-xs/node-comfort 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/Storage.js +6 -8
- package/package.json +1 -1
package/core/Storage.js
CHANGED
|
@@ -24,8 +24,8 @@ module.exports = class Storage {
|
|
|
24
24
|
/**
|
|
25
25
|
* @param {string} [path = ":memomry"]
|
|
26
26
|
*/
|
|
27
|
-
constructor(path) {
|
|
28
|
-
if (path.includes("/")) {
|
|
27
|
+
constructor(path = ":memory") {
|
|
28
|
+
if (path !== ":memory" && path.includes("/")) {
|
|
29
29
|
const split = path.split("/");
|
|
30
30
|
const file = split[split.length - 1];
|
|
31
31
|
const folder = FS.createPath(path.replace(file, ""));
|
|
@@ -37,15 +37,13 @@ module.exports = class Storage {
|
|
|
37
37
|
|
|
38
38
|
this.exec("PRAGMA journal_mode = WAL");
|
|
39
39
|
this.exec("PRAGMA foreign_keys = ON");
|
|
40
|
-
this.exec("PRAGMA synchronous = NORMAL");
|
|
41
|
-
this.exec("PRAGMA cache_size = -64000");
|
|
42
40
|
}
|
|
43
41
|
|
|
44
42
|
/**
|
|
45
43
|
* @param {string} sql
|
|
46
|
-
* @param {array|object} [options =
|
|
44
|
+
* @param {array|object} [options = []]
|
|
47
45
|
*/
|
|
48
|
-
exec(sql, options) {
|
|
46
|
+
exec(sql, options = []) {
|
|
49
47
|
try {
|
|
50
48
|
const stmt = this.#$.prepare(sql);
|
|
51
49
|
const result = stmt.run(...Checker.isArray(options) ? options : [options]);
|
|
@@ -64,7 +62,7 @@ module.exports = class Storage {
|
|
|
64
62
|
* @param {string} sql
|
|
65
63
|
* @param {array|object} [options = []]
|
|
66
64
|
*/
|
|
67
|
-
getOne(sql, options) {
|
|
65
|
+
getOne(sql, options = []) {
|
|
68
66
|
try {
|
|
69
67
|
const stmt = this.#$.prepare(sql);
|
|
70
68
|
|
|
@@ -78,7 +76,7 @@ module.exports = class Storage {
|
|
|
78
76
|
* @param {string} sql
|
|
79
77
|
* @param {array|object} [options = []]
|
|
80
78
|
*/
|
|
81
|
-
getAll(sql, options) {
|
|
79
|
+
getAll(sql, options = []) {
|
|
82
80
|
try {
|
|
83
81
|
const stmt = this.#$.prepare(sql);
|
|
84
82
|
|