oneday-core
Advanced tools
Comparing version 1.0.13 to 1.0.14
17
db.js
@@ -9,2 +9,4 @@ const aws = require('aws-sdk'); | ||
module.exports.queryDbElseThrow = queryDbElseThrow; | ||
module.exports.put = put; | ||
module.exports.transactionWrite = transactionWrite; | ||
@@ -87,2 +89,17 @@ async function getFromDbElseThrow(params, filter) { | ||
return result.Items; | ||
} | ||
async function put(params) { | ||
await dynamoDb.put(params).promise(); | ||
console.log("Successfully posted to: " + params.TableName); | ||
} | ||
async function transactionWrite(params) { | ||
await dynamoDb.transactWrite(params).promise(); | ||
console.log("Successfully committed transaction."); | ||
} | ||
async function update(params) { | ||
await dynamoDb.update(params).promise(); | ||
console.log("Successfully updated attribute."); | ||
} |
@@ -22,2 +22,4 @@ 'use strict'; | ||
module.exports.queryDbElseThrow = db.queryDbElseThrow; | ||
module.exports.put = db.put; | ||
module.exports.transactionWrite = db.transactionWrite; | ||
@@ -27,2 +29,4 @@ module.exports.hasProperties = util.hasProperties; | ||
module.exports.isObject = util.isObject; | ||
module.exports.get = util.get; | ||
module.exports.isPresent = util.isPresent; | ||
@@ -29,0 +33,0 @@ //ToDo: Add response code, global and lambda request tracking numbers |
{ | ||
"name": "oneday-core", | ||
"version": "1.0.13", | ||
"version": "1.0.14", | ||
"description": "Basic AWS util functions to ease development.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
10
util.js
@@ -7,2 +7,4 @@ module.exports.getDynamoDbArn = getDynamoDbArn; | ||
module.exports.isObject = isObject; | ||
module.exports.get = get; | ||
module.exports.isPresent = isPresent; | ||
@@ -66,2 +68,10 @@ function getDynamoDbArn(region, accountid, table) { | ||
function get(param){ | ||
return param === undefined ? null : param; | ||
} | ||
function isPresent(param){ | ||
return param !== undefined; | ||
} | ||
function isArray(a) { | ||
@@ -68,0 +78,0 @@ return (!!a) && (a.constructor === Array); |
15508
420