electrodb
Advanced tools
Comparing version 1.10.2 to 1.11.0
{ | ||
"name": "electrodb", | ||
"version": "1.10.2", | ||
"version": "1.11.0", | ||
"description": "A library to more easily create and interact with multiple entities and heretical relationships in dynamodb", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "mocha ./test/offline**.spec.js", | ||
"test-ts": "mocha -r ts-node/register ./test/**.spec.ts", | ||
"test-all": "mocha ./test/**.spec.js", | ||
"test-all-local": "LOCAL_DYNAMO_ENDPOINT=http://localhost:8000 node ./test/init.js && LOCAL_DYNAMO_ENDPOINT=http://localhost:8000 mocha ./test/**.spec.js && LOCAL_DYNAMO_ENDPOINT=http://localhost:8000 npm run test-ts && npm run test-types", | ||
"test": "npm run test-types && LOCAL_DYNAMO_ENDPOINT=http://localhost:8000 node ./test/init.js && LOCAL_DYNAMO_ENDPOINT=http://localhost:8000 mocha -r ts-node/register ./test/**.spec.*", | ||
"test-types": "tsd", | ||
"coverage": "nyc npm run test-all && nyc report --reporter=text-lcov | coveralls", | ||
"coverage-coveralls-local": "nyc npm run test-all-local && nyc report --reporter=text-lcov | coveralls", | ||
"coverage-html-local": "nyc npm run test-all-local && nyc report --reporter=html", | ||
"coverage": "nyc npm test && nyc report --reporter=text-lcov | coveralls", | ||
"coverage-coveralls-local": "nyc npm test && nyc report --reporter=text-lcov | coveralls", | ||
"coverage-html-local": "nyc npm test && nyc report --reporter=html", | ||
"build:browser": "browserify playground/browser.js -o playground/bundle.js" | ||
@@ -46,3 +43,3 @@ }, | ||
"source-map-support": "^0.5.19", | ||
"ts-node": "^10.8.1", | ||
"ts-node": "^10.8.2", | ||
"tsd": "^0.21.0", | ||
@@ -49,0 +46,0 @@ "typescript": "^4.7.4", |
@@ -1,2 +0,2 @@ | ||
const { QueryTypes, MethodTypes, ItemOperations, ExpressionTypes, TableIndex } = require("./types"); | ||
const { QueryTypes, MethodTypes, ItemOperations, ExpressionTypes, TableIndex, TerminalOperation } = require("./types"); | ||
const {AttributeOperationProxy, UpdateOperations, FilterOperationNames} = require("./operations"); | ||
@@ -582,2 +582,3 @@ const {UpdateExpression} = require("./update"); | ||
} | ||
options.terminalOperation = TerminalOperation.go; | ||
let params = clauses.params.action(entity, state, options); | ||
@@ -599,7 +600,8 @@ let {config} = entity._applyParameterOptions({}, state.getOptions(), options); | ||
try { | ||
options.page = page; | ||
options._isPagination = true; | ||
if (entity.client === undefined) { | ||
throw new e.ElectroError(e.ErrorCodes.NoClientDefined, "No client defined on model"); | ||
} | ||
options.page = page; | ||
options._isPagination = true; | ||
options.terminalOperation = TerminalOperation.page; | ||
let params = clauses.params.action(entity, state, options); | ||
@@ -606,0 +608,0 @@ let {config} = entity._applyParameterOptions({}, state.getOptions(), options); |
@@ -1,2 +0,2 @@ | ||
const { CastTypes, ValueTypes, KeyCasing, AttributeTypes, AttributeMutationMethods, AttributeWildCard, PathTypes, TraverserIndexes } = require("./types"); | ||
const { CastTypes, ValueTypes, KeyCasing, AttributeTypes, AttributeMutationMethods, AttributeWildCard, PathTypes } = require("./types"); | ||
const AttributeTypeNames = Object.keys(AttributeTypes); | ||
@@ -1266,3 +1266,3 @@ const ValidFacetTypes = [AttributeTypes.string, AttributeTypes.number, AttributeTypes.boolean, AttributeTypes.enum]; | ||
for (let [name, value] of Object.entries(payload)) { | ||
let field = this.translationForTable[name]; | ||
let field = this.getFieldName(name); | ||
if (value !== undefined) { | ||
@@ -1275,2 +1275,8 @@ record[field] = value; | ||
getFieldName(name) { | ||
if (typeof name === 'string') { | ||
return this.translationForTable[name]; | ||
} | ||
} | ||
checkCreate(payload = {}) { | ||
@@ -1325,5 +1331,7 @@ let record = {}; | ||
formatItemForRetrieval(item, config) { | ||
let returnAttributes = new Set(config.attributes || []); | ||
let hasUserSpecifiedReturnAttributes = returnAttributes.size > 0; | ||
let remapped = this.translateFromFields(item, config); | ||
let data = this._fulfillAttributeMutationMethod("get", remapped); | ||
if (this.hiddenAttributes.size > 0) { | ||
if (this.hiddenAttributes.size > 0 || hasUserSpecifiedReturnAttributes) { | ||
for (let attribute of Object.keys(data)) { | ||
@@ -1333,2 +1341,5 @@ if (this.hiddenAttributes.has(attribute)) { | ||
} | ||
if (hasUserSpecifiedReturnAttributes && !returnAttributes.has(attribute)) { | ||
delete data[attribute]; | ||
} | ||
} | ||
@@ -1335,0 +1346,0 @@ } |
@@ -189,2 +189,7 @@ const KeyTypes = { | ||
const TerminalOperation = { | ||
go: 'go', | ||
page: 'page', | ||
} | ||
module.exports = { | ||
@@ -214,2 +219,3 @@ Pager, | ||
AttributeWildCard, | ||
TerminalOperation, | ||
FormatToReturnValues, | ||
@@ -216,0 +222,0 @@ AttributeProxySymbol, |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
593508
8811
5901
22