electrodb 2.7.1 → 2.7.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/package.json
CHANGED
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "electrodb",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.2",
|
|
4
4
|
"description": "A library to more easily create and interact with multiple entities and heretical relationships in dynamodb",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"test": "npm run test:types && npm run test:init && npm run test:unit",
|
|
8
|
-
"test:init": "
|
|
9
|
-
"test:unit": "
|
|
7
|
+
"test:run": "npm run test:types && npm run test:init && npm run test:unit",
|
|
8
|
+
"test:init": "node ./test/init.js",
|
|
9
|
+
"test:unit": "mocha -r ts-node/register ./test/**.spec.*",
|
|
10
10
|
"test:types": "tsd",
|
|
11
11
|
"coverage": "npm run test:init && nyc npm run test:unit && nyc report --reporter=text-lcov | coveralls",
|
|
12
12
|
"coverage:local:coveralls": "npm run test:init && nyc npm run test:unit && nyc report --reporter=text-lcov | coveralls",
|
|
13
13
|
"coverage:local:html": "npm run test:init && nyc npm run test:unit && nyc report --reporter=html",
|
|
14
14
|
"build:browser": "browserify playground/browser.js -o playground/bundle.js",
|
|
15
15
|
"build": "sh buildbrowser.sh",
|
|
16
|
-
"
|
|
16
|
+
"test": "./test.sh",
|
|
17
|
+
"test:ci": "npm install && npm test",
|
|
18
|
+
"ddb:start": "docker compose up -d",
|
|
19
|
+
"ddb:load": "docker compose exec electro npm run test:init",
|
|
20
|
+
"ddb:stop": "docker compose stop",
|
|
21
|
+
"example:taskapp": "npm run ddb:start && npm run ddb:load && ts-node ./examples/taskmanager/src/index.ts; npm run ddb:stop"
|
|
17
22
|
},
|
|
18
23
|
"repository": {
|
|
19
24
|
"type": "git",
|
package/src/schema.js
CHANGED
|
@@ -542,8 +542,9 @@ class MapAttribute extends Attribute {
|
|
|
542
542
|
const getter = get || ((val) => {
|
|
543
543
|
const isEmpty = !val || Object.keys(val).length === 0;
|
|
544
544
|
const isNotRequired = !this.required;
|
|
545
|
+
const doesNotHaveDefault = this.default === undefined;
|
|
545
546
|
const isRoot = this.isRoot;
|
|
546
|
-
if (isEmpty && isRoot &&
|
|
547
|
+
if (isEmpty && isRoot && isNotRequired && doesNotHaveDefault) {
|
|
547
548
|
return undefined;
|
|
548
549
|
}
|
|
549
550
|
return val;
|
|
@@ -582,11 +583,16 @@ class MapAttribute extends Attribute {
|
|
|
582
583
|
const setter = set || ((val) => {
|
|
583
584
|
const isEmpty = !val || Object.keys(val).length === 0;
|
|
584
585
|
const isNotRequired = !this.required;
|
|
586
|
+
const doesNotHaveDefault = this.default === undefined;
|
|
587
|
+
const defaultIsValue = this.default === val;
|
|
585
588
|
const isRoot = this.isRoot;
|
|
586
|
-
if (
|
|
589
|
+
if (defaultIsValue) {
|
|
590
|
+
return val;
|
|
591
|
+
} else if (isEmpty && isRoot && isNotRequired && doesNotHaveDefault) {
|
|
587
592
|
return undefined;
|
|
593
|
+
} else {
|
|
594
|
+
return val;
|
|
588
595
|
}
|
|
589
|
-
return val;
|
|
590
596
|
});
|
|
591
597
|
|
|
592
598
|
return (values, siblings) => {
|
|
Binary file
|