ueberdb2 2.0.5 → 2.1.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Notable Changes
2
2
 
3
+ ## v2.1.0
4
+
5
+ * `memory`: New `data` setting that allows users to supply the backing Map
6
+ object (rather than create a new Map).
7
+
8
+ Updated database dependencies:
9
+
10
+ * `dirty_git`: Updated `simple-git` to 3.6.0.
11
+ * `mssql`: Updated `mssql` to 8.1.0.
12
+
3
13
  ## v2.0.0
4
14
 
5
15
  * When saving an object that has a `.toJSON()` method, the value returned from
@@ -28,7 +28,7 @@ exports.Database = class extends AbstractDatabase {
28
28
  }
29
29
 
30
30
  init() {
31
- this._data = new Map();
31
+ this._data = this.settings.data || new Map();
32
32
  }
33
33
 
34
34
  remove(key) {
package/package.json CHANGED
@@ -26,13 +26,13 @@
26
26
  "dirty": "^1.1.3",
27
27
  "elasticsearch": "^16.7.2",
28
28
  "mongodb": "^3.7.3",
29
- "mssql": "^7.3.0",
29
+ "mssql": "^8.1.0",
30
30
  "mysql": "2.18.1",
31
31
  "nano": "^9.0.5",
32
32
  "pg": "^8.7.1",
33
33
  "redis": "^3.1.2",
34
34
  "rethinkdb": "^2.4.2",
35
- "simple-git": "^3.3.0"
35
+ "simple-git": "^3.6.0"
36
36
  },
37
37
  "optionalDependencies": {
38
38
  "sqlite3": "github:mapbox/node-sqlite3#593c9d498be2510d286349134537e3bf89401c4a"
@@ -57,7 +57,7 @@
57
57
  "url": "https://github.com/ether/ueberDB.git"
58
58
  },
59
59
  "main": "./index",
60
- "version": "2.0.5",
60
+ "version": "2.1.0",
61
61
  "bugs": {
62
62
  "url": "https://github.com/ether/ueberDB/issues"
63
63
  },
@@ -0,0 +1,31 @@
1
+ 'use strict';
2
+
3
+ const assert = require('assert').strict;
4
+ const memory = require('../databases/memory_db');
5
+
6
+ describe(__filename, function () {
7
+ describe('data option', function () {
8
+ it('uses existing records from data option', async function () {
9
+ const db = new memory.Database({data: new Map([['foo', 'bar']])});
10
+ await db.init();
11
+ assert.equal(await db.get('foo'), 'bar');
12
+ });
13
+
14
+ it('updates existing map', async function () {
15
+ const data = new Map();
16
+ const db = new memory.Database({data});
17
+ await db.init();
18
+ await db.set('foo', 'bar');
19
+ assert.equal(data.get('foo'), 'bar');
20
+ });
21
+
22
+ it('does not clear map on close', async function () {
23
+ const data = new Map();
24
+ const db = new memory.Database({data});
25
+ await db.init();
26
+ await db.set('foo', 'bar');
27
+ await db.close();
28
+ assert.equal(data.get('foo'), 'bar');
29
+ });
30
+ });
31
+ });