electrodb 2.7.0 → 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 +11 -5
- package/src/entity.js +2 -1
- package/src/schema.js +9 -3
- package/.travis.yml +0 -15
- package/docker/dynamodb/shared-local-instance.db +0 -0
package/package.json
CHANGED
|
@@ -1,18 +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
|
-
"build": "sh buildbrowser.sh"
|
|
15
|
+
"build": "sh buildbrowser.sh",
|
|
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"
|
|
16
22
|
},
|
|
17
23
|
"repository": {
|
|
18
24
|
"type": "git",
|
package/src/entity.js
CHANGED
|
@@ -1969,7 +1969,8 @@ class Entity {
|
|
|
1969
1969
|
let operation = ItemOperations.set;
|
|
1970
1970
|
const name = this.model.schema.translationForRetrieval[field];
|
|
1971
1971
|
if (name) {
|
|
1972
|
-
|
|
1972
|
+
const attribute = this.model.schema.attributes[name];
|
|
1973
|
+
if (this.model.schema.readOnlyAttributes.has(name) && (!attribute || !attribute.indexes || attribute.indexes.length === 0)) {
|
|
1973
1974
|
operation = ItemOperations.ifNotExists;
|
|
1974
1975
|
}
|
|
1975
1976
|
}
|
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) => {
|
package/.travis.yml
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
language: node_js
|
|
2
|
-
|
|
3
|
-
services:
|
|
4
|
-
- docker
|
|
5
|
-
|
|
6
|
-
before_install:
|
|
7
|
-
- docker pull amazon/dynamodb-local
|
|
8
|
-
- docker run -p 8000:8000 --name dynamodb -d amazon/dynamodb-local
|
|
9
|
-
- docker ps -a
|
|
10
|
-
|
|
11
|
-
node_js:
|
|
12
|
-
- '16'
|
|
13
|
-
|
|
14
|
-
script:
|
|
15
|
-
- npm run coverage:local:coveralls
|
|
Binary file
|