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.1.3 to 0.1.4

60

actions/query.js

@@ -11,8 +11,29 @@ var once = require('once'),

var i, keySchema, key, comparisonOperator, firstKey, indexAttrs,
var i, keySchema, key, comparisonOperator, hashKey, rangeKey, indexAttrs, type,
opts = {}, vals, itemDb = store.getItemDb(data.TableName),
size = 0, capacitySize = 0, lastItem
if (data.ExclusiveStartKey && !Object.keys(data.ExclusiveStartKey).length) {
return cb(db.validationError('The provided starting key is invalid'))
hashKey = table.KeySchema[0].AttributeName
if (table.KeySchema[1]) rangeKey = table.KeySchema[1].AttributeName
if (data.ExclusiveStartKey) {
if (table.KeySchema.some(function(schemaPiece) { return !data.ExclusiveStartKey[schemaPiece.AttributeName] })) {
return cb(db.validationError('The provided starting key is invalid'))
}
comparisonOperator = data.KeyConditions[hashKey].ComparisonOperator
if (comparisonOperator == 'EQ') {
type = Object.keys(data.ExclusiveStartKey[hashKey])[0]
if (data.ExclusiveStartKey[hashKey][type] != data.KeyConditions[hashKey].AttributeValueList[0][type]) {
return cb(db.validationError('The provided starting key is outside query boundaries based on provided conditions'))
}
}
if (data.KeyConditions[rangeKey]) {
comparisonOperator = data.KeyConditions[rangeKey].ComparisonOperator
type = Object.keys(data.ExclusiveStartKey[rangeKey])[0]
// TODO: Need more extensive checking than this
if (comparisonOperator == 'GT' && data.ExclusiveStartKey[rangeKey][type] <= data.KeyConditions[rangeKey].AttributeValueList[0][type]) {
return cb(db.validationError('The provided starting key does not match the range key predicate'))
}
}
opts.start = db.validateKey(data.ExclusiveStartKey, table) + '\x00'
}

@@ -46,4 +67,3 @@

firstKey = Object.keys(data.KeyConditions)[0]
comparisonOperator = data.KeyConditions[firstKey].ComparisonOperator
comparisonOperator = data.KeyConditions[hashKey].ComparisonOperator
if (~['LE', 'LT', 'GE', 'GT', 'BEGINS_WITH', 'BETWEEN'].indexOf(comparisonOperator) ||

@@ -65,6 +85,2 @@ (keySchema.length == 1 && Object.keys(data.KeyConditions).length > 1))

if (data.ExclusiveStartKey) {
opts.start = db.validateKey(data.ExclusiveStartKey, table) + '\x00'
}
vals = db.lazy(itemDb.createValueStream(opts), cb)

@@ -112,18 +128,16 @@

if (data.ScanIndexForward === false) items.reverse()
// TODO: Check size?
// TODO: Does this only happen when we're not doing a COUNT?
if (data.Limit && (items.length > data.Limit || lastItem)) {
items.splice(data.Limit)
result.Count = items.length
if (result.Count) {
result.LastEvaluatedKey = table.KeySchema.reduce(function(key, schemaPiece) {
key[schemaPiece.AttributeName] = items[items.length - 1][schemaPiece.AttributeName]
return key
}, {})
}
}
// TODO: Check size?
// TODO: Does this only happen when we're not doing a COUNT?
if (data.Limit && (items.length > data.Limit || lastItem)) {
items.splice(data.Limit)
result.Count = items.length
if (result.Count) {
result.LastEvaluatedKey = table.KeySchema.reduce(function(key, schemaPiece) {
key[schemaPiece.AttributeName] = items[items.length - 1][schemaPiece.AttributeName]
return key
}, {})
}
result.Items = items
} else if (data.Limit && result.Count > data.Limit) {
result.Count = data.Limit
}
if (data.Select != 'COUNT') result.Items = items
if (data.ReturnConsumedCapacity == 'TOTAL')

@@ -130,0 +144,0 @@ result.ConsumedCapacity = {CapacityUnits: Math.ceil(capacitySize / 1024 / 4) * 0.5, TableName: data.TableName}

@@ -20,2 +20,6 @@ var once = require('once'),

if (data.ExclusiveStartKey) {
if (table.KeySchema.some(function(schemaPiece) { return !data.ExclusiveStartKey[schemaPiece.AttributeName] })) {
return cb(db.validationError('The provided starting key is invalid: ' +
'The provided key element does not match the schema'))
}
exclusiveLexiKey = db.validateKey(data.ExclusiveStartKey, table)

@@ -22,0 +26,0 @@ if (data.TotalSegments > 1 && (exclusiveLexiKey < opts.start || exclusiveLexiKey > opts.end)) {

{
"name": "dynalite",
"version": "0.1.3",
"version": "0.1.4",
"description": "A mock implementation of Amazon's DynamoDB built on LevelDB",

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

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