New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

dynamomo

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dynamomo - npm Package Compare versions

Comparing version 0.1.0-beta.4 to 0.1.0-beta.5

14

index.js

@@ -1,13 +0,1 @@

'use strict'
/**
* Dynamomo
*/
const DynamoDB = require('./dynamodb')
module.exports = {
create: require('./table').create,
client: DynamoDB.client,
db: DynamoDB.db,
config: require('./config'),
getPolicy: require('./table-session').getPolicy
}
module.exports = require("./table");

2

package.json
{
"name": "dynamomo",
"version": "0.1.0-beta.4",
"version": "0.1.0-beta.5",
"description": "Dynamodb query helper",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -26,3 +26,3 @@ # Dynamomo

# Import
# Usage
---

@@ -33,2 +33,7 @@

import dynamomo from 'dynamomo'
const myDynamomo = dynamomo({ region: 'us-east-1' })
const itemsTable = myDynamomo.create('items')
const myItem = itemsTable.getById(1)
```

@@ -44,6 +49,8 @@

// Configure table with stage
// Configure dynamomo with table prefix and logging
dynamomo.config({
tablePrefix: stage, // takes care of prefixing for different stages
debug: true // outputs dynamodb usage information as you query
debug: true, // outputs dynamodb usage information as you query
tablePrefix: 'prod', // takes care of prefixing for tables.
// eg: table name 'items' will be 'prod-items'
})

@@ -50,0 +57,0 @@

'use strict'
const AWS = require('aws-sdk')
const chalk = require('chalk')

@@ -12,7 +13,20 @@ const _chunk = require('lodash/chunk')

const docClient = require('../dynamodb').client
const config = require('../config')
const Task = require('../task-message')
const session = require('../table-session')
// Don't set a default for tablePrefix in case it's not needed for a table
// tablePrefix equates to stage - prod, dev, int
let tablePrefix
let debug = false
let docClient
function config(params) {
params = params || {}
tablePrefix = params.tablePrefix || params.stage
debug = params.debug === true
}
config.getTablePrefix = () => tablePrefix
config.isDebug = () => debug
/**

@@ -24,3 +38,3 @@ * Checks data for Amazon types and

*/
function transformData (data) {
function transformData(data) {
if (_get(data, 'constructor.name') === 'Set') {

@@ -38,3 +52,3 @@ return data.values || data

function createRequest (action, startParams) {
function createRequest(action, startParams) {
startParams = startParams || {}

@@ -86,3 +100,3 @@ // remove MaxLimit property

doAction(params)
function doAction (params) {
function doAction(params) {
docClient[action](params)

@@ -175,3 +189,3 @@ .promise()

*/
function getTableName () {
function getTableName() {
const tablePrefix = this.tablePrefix || config.getTablePrefix()

@@ -200,3 +214,3 @@ if (this.noPrefix) {

*/
function getById (Id, addParams) {
function getById(Id, addParams) {
addParams = addParams || {}

@@ -225,3 +239,3 @@

*/
function getByKey (keys) {
function getByKey(keys) {
return createRequest('get', {

@@ -240,3 +254,3 @@ TableName: this.getTableName(),

*/
function scan (params) {
function scan(params) {
params = params || {}

@@ -255,3 +269,3 @@ params.TableName = this.getTableName()

*/
function getAllById (IdArray) {
function getAllById(IdArray) {
const reqIds = _chunk(IdArray.map(id => ({ Id: id })), 100)

@@ -292,3 +306,3 @@

*/
function query (params) {
function query(params) {
params = params || {}

@@ -311,3 +325,3 @@ params.TableName = this.getTableName()

*/
function queryByKeys (queryKeys, addParams) {
function queryByKeys(queryKeys, addParams) {
addParams = addParams || {}

@@ -340,3 +354,3 @@

*/
function update (params) {
function update(params) {
params = params || {}

@@ -353,3 +367,3 @@ params.TableName = this.getTableName()

*/
function put (params) {
function put(params) {
params = params || {}

@@ -366,3 +380,3 @@ params.TableName = this.getTableName()

*/
function updateById (Id, updateKeys, addParams) {
function updateById(Id, updateKeys, addParams) {
addParams = addParams || {}

@@ -400,3 +414,3 @@ addParams.TableName = this.getTableName()

*/
function deleteById (Id, addParams) {
function deleteById(Id, addParams) {
addParams = addParams || {}

@@ -420,3 +434,3 @@ addParams.TableName = this.getTableName()

*/
function CreateTable (name, options) {
function CreateTable(name, options) {
if (!name) {

@@ -472,2 +486,3 @@ throw new Error('dynamomo: createTable requires a name to initialize')

module.exports.config = config
module.exports.client = docClient

@@ -477,1 +492,27 @@ module.exports.create = function (tableName, options) {

}
module.exports = function dynamomo(awsConfig) {
const DynamoDB = new AWS.DynamoDB(
Object.assign(
{
apiVersion: '2012-08-10'
},
awsConfig
)
)
// scope declared at the module level - not awesome
docClient = new AWS.DynamoDB.DocumentClient(awsConfig)
config({ tablePrefix, debug })
return {
create: function (tableName, options) {
return new CreateTable(tableName, options)
},
client: DynamoDB.client,
db: DynamoDB.db,
config: config,
getPolicy: require('../table-session').getPolicy
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc