UNPKG

dynamodb-toolbox

Version:

Lightweight and type-safe query builder for DynamoDB and TypeScript.

36 lines (35 loc) 1.74 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.parseGetItemOptions = void 0; const index_js_1 = require("../../../../entity/actions/parsePaths/index.js"); const capacity_js_1 = require("../../../../options/capacity.js"); const consistent_js_1 = require("../../../../options/consistent.js"); const rejectExtraOptions_js_1 = require("../../../../options/rejectExtraOptions.js"); const tableName_js_1 = require("../../../../options/tableName.js"); const isEmpty_js_1 = require("../../../../utils/isEmpty.js"); const parseGetItemOptions = (entity, getItemOptions) => { const commandOptions = {}; const { capacity, consistent, attributes, tableName, ...extraOptions } = getItemOptions; (0, rejectExtraOptions_js_1.rejectExtraOptions)(extraOptions); if (capacity !== undefined) { commandOptions.ReturnConsumedCapacity = (0, capacity_js_1.parseCapacityOption)(capacity); } if (consistent !== undefined) { commandOptions.ConsistentRead = (0, consistent_js_1.parseConsistentOption)(consistent); } if (attributes !== undefined) { const { ExpressionAttributeNames, ProjectionExpression } = entity .build(index_js_1.EntityPathParser) .parse(attributes); if (!(0, isEmpty_js_1.isEmpty)(ExpressionAttributeNames)) { commandOptions.ExpressionAttributeNames = ExpressionAttributeNames; } commandOptions.ProjectionExpression = ProjectionExpression; } if (tableName !== undefined) { // tableName is a meta-option, validated but not used here (0, tableName_js_1.parseTableNameOption)(tableName); } return commandOptions; }; exports.parseGetItemOptions = parseGetItemOptions;