@sprucelabs/data-stores 18.0.7 → 18.0.8

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.
@@ -6,5 +6,6 @@ export default class DatabaseFactory {
6
6
  dbName: string;
7
7
  dbConnectionString: string;
8
8
  }): Database;
9
+ private static generateCacheKey;
9
10
  static reset(): void;
10
11
  }
@@ -13,7 +13,7 @@ export default class DatabaseFactory {
13
13
  friendlyMessage: "DatabaseFactory can't connect to the database! Setting env.DB_CONNECTION_STRING may help!",
14
14
  });
15
15
  }
16
- const cacheKey = options.dbName + options.dbConnectionString;
16
+ const cacheKey = this.generateCacheKey(options);
17
17
  if (!this.cache[cacheKey]) {
18
18
  if (dbConnectionString.startsWith('memory')) {
19
19
  database = new NeDbDatabase();
@@ -25,6 +25,12 @@ export default class DatabaseFactory {
25
25
  }
26
26
  return this.cache[cacheKey];
27
27
  }
28
+ static generateCacheKey(options) {
29
+ if (!options.dbName && options.dbConnectionString.includes('memory')) {
30
+ options.dbName = 'memory';
31
+ }
32
+ return options.dbName + options.dbConnectionString;
33
+ }
28
34
  static reset() {
29
35
  this.cache = {};
30
36
  }
@@ -6,5 +6,6 @@ export default class DatabaseFactory {
6
6
  dbName: string;
7
7
  dbConnectionString: string;
8
8
  }): Database;
9
+ private static generateCacheKey;
9
10
  static reset(): void;
10
11
  }
@@ -18,7 +18,7 @@ class DatabaseFactory {
18
18
  friendlyMessage: "DatabaseFactory can't connect to the database! Setting env.DB_CONNECTION_STRING may help!",
19
19
  });
20
20
  }
21
- const cacheKey = options.dbName + options.dbConnectionString;
21
+ const cacheKey = this.generateCacheKey(options);
22
22
  if (!this.cache[cacheKey]) {
23
23
  if (dbConnectionString.startsWith('memory')) {
24
24
  database = new NeDbDatabase_1.default();
@@ -30,6 +30,12 @@ class DatabaseFactory {
30
30
  }
31
31
  return this.cache[cacheKey];
32
32
  }
33
+ static generateCacheKey(options) {
34
+ if (!options.dbName && options.dbConnectionString.includes('memory')) {
35
+ options.dbName = 'memory';
36
+ }
37
+ return options.dbName + options.dbConnectionString;
38
+ }
33
39
  static reset() {
34
40
  this.cache = {};
35
41
  }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "18.0.7",
6
+ "version": "18.0.8",
7
7
  "files": [
8
8
  "build/**/*",
9
9
  "!build/__tests__",