@makano/rew 1.2.43 → 1.2.44

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.
@@ -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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@makano/rew",
3
- "version": "1.2.43",
3
+ "version": "1.2.44",
4
4
  "description": "A simple coffescript runtime and app manager",
5
5
  "main": "main.js",
6
6
  "directories": {