brackets-json-db 0.1.0 → 1.0.2
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/README.md +5 -0
- package/dist/index.js +4 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# brackets-json-db
|
|
2
|
+
|
|
3
|
+
This implementation of the [`CrudInterface`](https://drarig29.github.io/brackets-docs/reference/manager/interfaces/CrudInterface.html) uses [node-json-db](https://github.com/Belphemur/node-json-db) to use a JSON file as a database.
|
|
4
|
+
|
|
5
|
+
This is used in the tests of the [manager](https://github.com/Drarig29/brackets-manager.js).
|
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
|
}
|