duenamodb
Version:
Simple DynamoDB client written in TypeScript.
27 lines • 1 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.putItem = exports.createPutItem = void 0;
const client_dynamodb_1 = require("@aws-sdk/client-dynamodb");
const util_dynamodb_1 = require("@aws-sdk/util-dynamodb");
const client_1 = require("./client");
const createPutItem = (tablename) => {
return (item, options = {}) => (0, exports.putItem)(tablename, (0, util_dynamodb_1.marshall)(item), options);
};
exports.createPutItem = createPutItem;
const putItem = async (tableName, input, options) => {
if (!input) {
throw new Error('Missing put item input');
}
const command = new client_dynamodb_1.PutItemCommand({
...options,
Item: input,
TableName: tableName,
});
const res = await client_1.DDBClient.instance.send(command);
if (res.$metadata.httpStatusCode !== 200) {
throw res;
}
return (0, util_dynamodb_1.unmarshall)(input);
};
exports.putItem = putItem;
//# sourceMappingURL=put.js.map