brackets-json-db 1.0.1 → 1.0.3
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/dist/index.d.ts +1 -1
- package/dist/index.js +17 -4
- package/package.json +3 -2
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -119,6 +119,8 @@ class JsonDatabase {
|
|
|
119
119
|
return this.internal.getData(JsonDatabase.makePath(table)).map(clone);
|
|
120
120
|
if (typeof arg === 'number') {
|
|
121
121
|
const index = this.internal.getIndex(JsonDatabase.makePath(table), arg);
|
|
122
|
+
if (index === -1)
|
|
123
|
+
return null;
|
|
122
124
|
return clone(this.internal.getData(JsonDatabase.makeArrayIndexPath(table, index)));
|
|
123
125
|
}
|
|
124
126
|
const values = this.internal.filter(JsonDatabase.makePath(table), this.makeFilter(arg)) || null;
|
|
@@ -139,6 +141,8 @@ class JsonDatabase {
|
|
|
139
141
|
if (typeof arg === 'number') {
|
|
140
142
|
try {
|
|
141
143
|
const index = this.internal.getIndex(JsonDatabase.makePath(table), arg);
|
|
144
|
+
if (index === -1)
|
|
145
|
+
return false;
|
|
142
146
|
this.internal.push(JsonDatabase.makeArrayIndexPath(table, index), value);
|
|
143
147
|
return true;
|
|
144
148
|
}
|
|
@@ -146,11 +150,20 @@ class JsonDatabase {
|
|
|
146
150
|
return false;
|
|
147
151
|
}
|
|
148
152
|
}
|
|
149
|
-
|
|
150
|
-
|
|
153
|
+
try {
|
|
154
|
+
const values = this.internal.filter(JsonDatabase.makePath(table), this.makeFilter(arg));
|
|
155
|
+
if (!values)
|
|
156
|
+
return false;
|
|
157
|
+
values.forEach((v) => {
|
|
158
|
+
const index = this.internal.getIndex(JsonDatabase.makePath(table), v.id);
|
|
159
|
+
if (index !== -1)
|
|
160
|
+
this.internal.push(JsonDatabase.makeArrayIndexPath(table, index), value, false);
|
|
161
|
+
});
|
|
162
|
+
return true;
|
|
163
|
+
}
|
|
164
|
+
catch (error) {
|
|
151
165
|
return false;
|
|
152
|
-
|
|
153
|
-
return true;
|
|
166
|
+
}
|
|
154
167
|
}
|
|
155
168
|
/**
|
|
156
169
|
* Delete data in a table, based on a filter.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "brackets-json-db",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "An in-memory database for brackets-manager.js",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
],
|
|
19
19
|
"scripts": {
|
|
20
20
|
"build": "tsc",
|
|
21
|
+
"test": "node --test ../test/implementations/json.test.js",
|
|
21
22
|
"prepare": "npm run build",
|
|
22
23
|
"prepublishOnly": "npm run build"
|
|
23
24
|
},
|
|
@@ -35,7 +36,7 @@
|
|
|
35
36
|
"typescript": "^4.4.4"
|
|
36
37
|
},
|
|
37
38
|
"peerDependencies": {
|
|
38
|
-
"brackets-
|
|
39
|
+
"brackets-model": "^1.7.0"
|
|
39
40
|
},
|
|
40
41
|
"dependencies": {
|
|
41
42
|
"node-json-db": "^1.4.1",
|