@makano/rew 1.2.43 → 1.2.44
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/rew/pkgs/rune.js +8 -1
- package/package.json +1 -1
package/lib/rew/pkgs/rune.js
CHANGED
@@ -169,6 +169,7 @@ const createDB = (dbName, dirname, dbData = {}, encryptionKey) => {
|
|
169
169
|
};
|
170
170
|
|
171
171
|
const update = (caseRecord, newRecord) => {
|
172
|
+
|
172
173
|
let id;
|
173
174
|
if (typeof caseRecord === 'string') {
|
174
175
|
id = caseRecord;
|
@@ -224,6 +225,9 @@ const createDB = (dbName, dirname, dbData = {}, encryptionKey) => {
|
|
224
225
|
if (typeof criteria == 'string') return read(criteria);
|
225
226
|
if (!criteria || typeof criteria !== 'object') return null;
|
226
227
|
|
228
|
+
|
229
|
+
if (!fs.existsSync(collectionFilePath)) writeDataFile(collectionFilePath, []);
|
230
|
+
|
227
231
|
const data = readDataFile(collectionFilePath);
|
228
232
|
const record =
|
229
233
|
data.find((record) => {
|
@@ -240,7 +244,6 @@ const createDB = (dbName, dirname, dbData = {}, encryptionKey) => {
|
|
240
244
|
|
241
245
|
const remove = (id) => {
|
242
246
|
if ('@rune.id' in id) id = id['@rune.id'];
|
243
|
-
if (!fs.existsSync(collectionFilePath)) return false;
|
244
247
|
let data = readDataFile(collectionFilePath);
|
245
248
|
const index = data.findIndex((record) => record['@rune.id'] === id);
|
246
249
|
if (index !== -1) {
|
@@ -293,6 +296,8 @@ const createDB = (dbName, dirname, dbData = {}, encryptionKey) => {
|
|
293
296
|
return sortedData;
|
294
297
|
};
|
295
298
|
|
299
|
+
if (!fs.existsSync(collectionFilePath)) writeDataFile(collectionFilePath, []);
|
300
|
+
|
296
301
|
return {
|
297
302
|
insert,
|
298
303
|
read,
|
@@ -377,6 +382,8 @@ const createDB = (dbName, dirname, dbData = {}, encryptionKey) => {
|
|
377
382
|
return data;
|
378
383
|
};
|
379
384
|
|
385
|
+
if (!fs.existsSync(mapFilePath)) writeDataFile(mapFilePath, {});
|
386
|
+
|
380
387
|
return { set, get, remove, list, transform };
|
381
388
|
};
|
382
389
|
|