Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dynalite

Package Overview
Dependencies
Maintainers
1
Versions
121
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dynalite - npm Package Compare versions

Comparing version 0.6.2 to 0.7.0

19

actions/query.js

@@ -15,3 +15,3 @@ var events = require('events'),

opts = {}, vals, itemDb = store.getItemDb(data.TableName),
size = 0, capacitySize = 0, count = 0, lastItem, em
size = 0, capacitySize = 0, count = 0, scannedCount = 0, lastItem, em

@@ -163,2 +163,15 @@ if (data.IndexName) {

if (data.QueryFilter) {
for (i = 0; i < keySchema.length; i++) {
if (data.QueryFilter[keySchema[i].AttributeName])
return cb(db.validationError('QueryFilter can only contain non-primary key attributes: ' +
'Primary key attribute: ' + keySchema[i].AttributeName))
}
vals = vals.filter(function(val) {
scannedCount++
return db.matchesFilter(val, data.QueryFilter)
})
}
if (data.AttributesToGet) {

@@ -174,3 +187,3 @@ vals = vals.map(function(val) {

vals.join(function(items) {
var result = {Count: items.length, ScannedCount: items.length}
var result = {Count: items.length, ScannedCount: scannedCount || items.length}

@@ -182,3 +195,3 @@ // TODO: Check size?

result.Count = items.length
result.ScannedCount = items.length
result.ScannedCount = scannedCount || items.length
if (result.Count) {

@@ -185,0 +198,0 @@ result.LastEvaluatedKey = table.KeySchema.concat(keySchema).reduce(function(key, schemaPiece) {

2

package.json
{
"name": "dynalite",
"version": "0.6.2",
"version": "0.7.0",
"description": "A mock implementation of Amazon's DynamoDB built on LevelDB",

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

@@ -41,2 +41,38 @@ var validateAttributeValue = require('./index').validateAttributeValue

},
QueryFilter: {
type: 'Map',
children: {
type: 'Structure',
children: {
AttributeValueList: {
type: 'List',
children: {
type: 'Structure',
children: {
S: 'String',
B: 'Blob',
N: 'String',
BS: {
type: 'List',
children: 'Blob',
},
NS: {
type: 'List',
children: 'String',
},
SS: {
type: 'List',
children: 'String',
}
}
}
},
ComparisonOperator: {
type: 'String',
notNull: true,
enum: ['IN', 'NULL', 'BETWEEN', 'LT', 'NOT_CONTAINS', 'EQ', 'GT', 'NOT_NULL', 'NE', 'LE', 'BEGINS_WITH', 'GE', 'CONTAINS']
}
}
}
},
Select: {

@@ -102,3 +138,3 @@ type: 'String',

return 'Conditions must not be null'
var conditionKeys = Object.keys(data.KeyConditions)
var conditionKeys = Object.keys(data.KeyConditions), key, comparisonOperator, attrValList

@@ -121,5 +157,18 @@ var msg = '', i

}
for (var key in data.KeyConditions) {
var comparisonOperator = data.KeyConditions[key].ComparisonOperator
var attrValList = data.KeyConditions[key].AttributeValueList || []
var types = {
EQ: ['S', 'N', 'B', 'SS', 'NS', 'BS'],
NE: ['S', 'N', 'B', 'SS', 'NS', 'BS'],
LE: ['S', 'N', 'B'],
LT: ['S', 'N', 'B'],
GE: ['S', 'N', 'B'],
GT: ['S', 'N', 'B'],
CONTAINS: ['S', 'N', 'B'],
NOT_CONTAINS: ['S', 'N', 'B'],
BEGINS_WITH: ['S', 'B'],
IN: ['S', 'N', 'B'],
BETWEEN: ['S', 'N', 'B'],
}
for (key in data.KeyConditions) {
comparisonOperator = data.KeyConditions[key].ComparisonOperator
attrValList = data.KeyConditions[key].AttributeValueList || []
for (i = 0; i < attrValList.length; i++) {

@@ -129,2 +178,3 @@ msg = validateAttributeValue(attrValList[i])

}
if ((typeof lengths[comparisonOperator] == 'number' && attrValList.length != lengths[comparisonOperator]) ||

@@ -134,2 +184,10 @@ (attrValList.length < lengths[comparisonOperator][0] || attrValList.length > lengths[comparisonOperator][1]))

comparisonOperator + ' ComparisonOperator'
if (types[comparisonOperator]) {
for (i = 0; i < attrValList.length; i++) {
if (!~types[comparisonOperator].indexOf(Object.keys(attrValList[i])[0]))
return 'One or more parameter values were invalid: ComparisonOperator ' + comparisonOperator +
' is not valid for ' + Object.keys(attrValList[i])[0] + ' AttributeValue type'
}
}
}

@@ -141,9 +199,29 @@

if (data.ExclusiveStartKey) {
for (key in data.ExclusiveStartKey) {
msg = validateAttributeValue(data.ExclusiveStartKey[key])
if (msg) return 'The provided starting key is invalid: ' + msg
for (key in data.QueryFilter) {
comparisonOperator = data.QueryFilter[key].ComparisonOperator
attrValList = data.QueryFilter[key].AttributeValueList || []
for (i = 0; i < attrValList.length; i++) {
msg = validateAttributeValue(attrValList[i])
if (msg) return msg
}
if ((typeof lengths[comparisonOperator] == 'number' && attrValList.length != lengths[comparisonOperator]) ||
(attrValList.length < lengths[comparisonOperator][0] || attrValList.length > lengths[comparisonOperator][1]))
return 'One or more parameter values were invalid: Invalid number of argument(s) for the ' +
comparisonOperator + ' ComparisonOperator'
if (types[comparisonOperator]) {
for (i = 0; i < attrValList.length; i++) {
if (!~types[comparisonOperator].indexOf(Object.keys(attrValList[i])[0]))
return 'One or more parameter values were invalid: ComparisonOperator ' + comparisonOperator +
' is not valid for ' + Object.keys(attrValList[i])[0] + ' AttributeValue type'
}
}
}
for (key in data.ExclusiveStartKey) {
msg = validateAttributeValue(data.ExclusiveStartKey[key])
if (msg) return 'The provided starting key is invalid: ' + msg
}
if (data.AttributesToGet) {

@@ -150,0 +228,0 @@ var attrs = Object.create(null)

@@ -150,7 +150,5 @@ var validateAttributeValue = require('./index').validateAttributeValue

if (data.ExclusiveStartKey) {
for (key in data.ExclusiveStartKey) {
msg = validateAttributeValue(data.ExclusiveStartKey[key])
if (msg) return 'The provided starting key is invalid: ' + msg
}
for (key in data.ExclusiveStartKey) {
msg = validateAttributeValue(data.ExclusiveStartKey[key])
if (msg) return 'The provided starting key is invalid: ' + msg
}

@@ -157,0 +155,0 @@

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