Skip to content

Commit 06d9f7e

Browse files
author
Phillip Gates-Idem
authored
Merge pull request #50 from JupiterOne/NOTICKET-remove-default-query-limit
Remove default query limit
2 parents a2317c7 + 23dd7c5 commit 06d9f7e

File tree

5 files changed

+8
-103
lines changed

5 files changed

+8
-103
lines changed

.github/workflows/peril.yml

Lines changed: 0 additions & 90 deletions
This file was deleted.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@jupiterone/dynamodb-dao",
3-
"version": "1.8.0",
3+
"version": "1.9.0",
44
"description": "DynamoDB Data Access Object (DAO) helper library",
55
"repository": {
66
"type": "git",

src/constants.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
export const DEFAULT_QUERY_LIMIT = 50;
21
export const MAX_BATCH_OPERATIONS = 25;
32
export const DEFAULT_LOCK_INCREMENT = 1;

src/index.test.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import * as AWS from 'aws-sdk';
22
import { v4 as uuid } from 'uuid';
33
import DynamoDbDao from '.';
44
import mockLogger from '../test/helpers/mockLogger';
5-
import { DEFAULT_QUERY_LIMIT } from './constants';
65
import { CountOutput } from './types';
76
import { generateUpdateParams } from './update/generateUpdateParams';
87

@@ -211,7 +210,6 @@ test(`#query should have default query limit`, async () => {
211210
expect(documentClient.query).toHaveBeenCalledWith({
212211
TableName: tableName,
213212
IndexName: index,
214-
Limit: DEFAULT_QUERY_LIMIT,
215213
ExclusiveStartKey: undefined,
216214
KeyConditionExpression: keyConditionExpression,
217215
ExpressionAttributeValues: attributeValues,
@@ -509,7 +507,6 @@ test('#scan should allow consistent reads', async () => {
509507

510508
expect(documentClient.scan).toHaveBeenCalledWith({
511509
ConsistentRead: true,
512-
Limit: 50,
513510
TableName: tableName,
514511
});
515512
});

src/index.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@ import { sleep } from '@lifeomic/attempt';
22
import { DocumentClient } from 'aws-sdk/clients/dynamodb';
33
import chunk from 'lodash.chunk';
44
import pMap from 'p-map';
5-
import {
6-
DEFAULT_LOCK_INCREMENT,
7-
DEFAULT_QUERY_LIMIT,
8-
MAX_BATCH_OPERATIONS,
9-
} from './constants';
5+
import { DEFAULT_LOCK_INCREMENT, MAX_BATCH_OPERATIONS } from './constants';
106
import { buildOptimisticLockOptions } from './locking/buildOptimisticLockOptions';
117
import {
128
decodeQueryUntilLimitCursor,
@@ -181,7 +177,10 @@ export default class DynamoDbDao<DataModel, KeySchema> {
181177

182178
// If the version attribute is supplied, increment it, otherwise only
183179
// set the default if directed to do so
184-
if (versionAttribute in data && !isNaN(dataAsMap[versionAttribute])) {
180+
if (
181+
versionAttribute in dataAsMap &&
182+
!isNaN(dataAsMap[versionAttribute])
183+
) {
185184
dataAsMap[versionAttribute] += DEFAULT_LOCK_INCREMENT;
186185
} else if (this.autoInitiateLockingAttribute) {
187186
dataAsMap[versionAttribute] = DEFAULT_LOCK_INCREMENT;
@@ -354,7 +353,7 @@ export default class DynamoDbDao<DataModel, KeySchema> {
354353
scanIndexForward,
355354
keyConditionExpression,
356355
filterExpression,
357-
limit = DEFAULT_QUERY_LIMIT,
356+
limit,
358357
consistentRead,
359358
} = input;
360359

@@ -475,7 +474,7 @@ export default class DynamoDbDao<DataModel, KeySchema> {
475474
filterExpression,
476475
segment,
477476
totalSegments,
478-
limit = DEFAULT_QUERY_LIMIT,
477+
limit,
479478
consistentRead,
480479
} = input;
481480

0 commit comments

Comments
 (0)