@jasongilbertuk/dynamo-helper v1.0.4
dynamo-helper
A selection of helper functions when working with DynamoDB
resetConfig
Writes the application control configuration to the table. Very application specific. Throws exception on unexpected errors.
const {resetConfig} = require('@jasongilbertuk/dynamo-helper)
try {
const result = await resetConfig("myTableName");
} catch (err) {
//Your error handling logic
console.log(err);
}
writeItemToTable
Writes the item to the table. Throws exception on unexpected errors.
const {writeItemToTable} = require('@jasongilbertuk/dynamo-helper)
try {
var myItem = { id: "1", name: 'jason'}
const result = await writeItemToTable("myTableName",myItem)
} catch (err) {
//Your error handling logic
console.log(err);
}
readItemFromTable
Reads the defined attributes from the entry in the the table with the id specified. Throws exception on unexpected errors.
const {readItemFromTable} = require('@jasongilbertuk/dynamo-helper)
try {
const id = "1"
const attributes = ["name"]
const result = await readItemFromTable("myTableName",id,attributes);
} catch (err) {
//Your error handling logic
console.log(err);
}
readConfig
Reads the application configuration from the table. Throws exception on unexpected errors.
const {readConfig} = require('@jasongilbertuk/dynamo-helper)
try {
const result = await readConfig("myTableName")
} catch (err) {
//Your error handling logic
console.log(err);
}
createTable
Creates the database. Returns true if successful. Note: This function is very app specific Throws exception on unexpected errors.
const {createTable} = require('@jasongilbertuk/dynamo-helper)
try {
const result = await createTable("myTableName")
} catch (err) {
//Your error handling logic
console.log(err);
}
createTableIfDoesntExist
Checks to see if database exists, and creates it if not. Returns true if database exists, false otherwise. Throws exception on unexpected errors.
const {createTableIfDoesntExist} = require('@jasongilbertuk/dynamo-helper)
try {
const result = await createTableIfDoesntExist("myTableName")
} catch (err) {
//Your error handling logic
console.log(err);
}
deleteTable
Deletes the named table. Returns true if succeeds, false if table doesnt exist. Throws exception on unexpected errors.
const {deleteTable = require('@jasongilbertuk/dynamo-helper)
try {
const result = await deleteTable("myTableName")
} catch (err) {
//Your error handling logic
console.log(err);
}