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

cruft-ddb

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cruft-ddb - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

17

lib/findAll.js

@@ -12,2 +12,6 @@ "use strict";

const assertHasValidDynamoDBFieldNames_1 = require("./assertHasValidDynamoDBFieldNames");
const createFilterExpression = (fieldNames, fields) => fieldNames.reduce((obj, key) => {
obj[`:${key}`] = fields[key];
return obj;
}, {});
// hack to retrieve all items until 2.3 arrives with support for async iterators

@@ -21,8 +25,9 @@ // https://github.com/Microsoft/TypeScript/pull/12346

const fieldNames = Object.keys(fields);
const filterExpression = fieldNames.map(key => `${key} = :${key}`)
.join(' and ');
const expressionAtributeValues = fieldNames.reduce((obj, key) => {
obj[`:${key}`] = fields[key];
return obj;
}, {});
const filterExpression = fieldNames.length === 0
? null
: fieldNames.map(key => `${key} = :${key}`)
.join(' and ');
const expressionAtributeValues = fieldNames.length === 0
? null
: createFilterExpression(fieldNames, fields);
let result = [];

@@ -29,0 +34,0 @@ let key = null;

{
"name": "cruft-ddb",
"version": "1.0.2",
"version": "1.0.3",
"description": "A simple optimistic-locking abstraction over Dynamo DB",

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

import { assertHasValidDynamoDBFieldNames } from './assertHasValidDynamoDBFieldNames';
import { IConfiguration, IHasVersion, IHasMetadata } from './index';
const createFilterExpression = (fieldNames, fields) =>
fieldNames.reduce(
(obj, key) => {
obj[`:${key}`] = fields[key];
return obj;
},
{}
);
// hack to retrieve all items until 2.3 arrives with support for async iterators

@@ -16,12 +25,10 @@ // https://github.com/Microsoft/TypeScript/pull/12346

const filterExpression = fieldNames.map(key => `${key} = :${key}`)
.join(' and ');
const filterExpression = fieldNames.length === 0
? null
: fieldNames.map(key => `${key} = :${key}`)
.join(' and ');
const expressionAtributeValues = fieldNames.reduce(
(obj, key) => {
obj[`:${key}`] = fields[key];
return obj;
},
{}
);
const expressionAtributeValues = fieldNames.length === 0
? null
: createFilterExpression(fieldNames, fields);

@@ -28,0 +35,0 @@ let result: Array<T & IHasVersion & IHasMetadata> = [];

@@ -171,2 +171,20 @@ import { DynamoDB } from 'aws-sdk';

describe('__findAll', async () => {
it('should find items without filter', async () => {
await cruft.create({ id: 'foo', bar: 4 });
const items = await cruft.__findAll({});
expect(items).to.lengthOf(1, 'Incorrect item count');
});
(<any>it)('should find items over many pages', async () => {
for (let i = 0; i < 1000; i++) {
await cruft.create({ id: String(i), bar: 4 });
}
const items = await cruft.__findAll({ bar: 4 });
expect(items).to.lengthOf(1000, 'Incorrect item count');
}, 60000);
});
describe('truncate', () => {

@@ -173,0 +191,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