Skip to content

Commit

Permalink
Merge pull request #50 from JupiterOne/NOTICKET-remove-default-query-…
Browse files Browse the repository at this point in the history
…limit

Remove default query limit
  • Loading branch information
Phillip Gates-Idem authored Apr 24, 2024
2 parents a2317c7 + 23dd7c5 commit 06d9f7e
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 103 deletions.
90 changes: 0 additions & 90 deletions .github/workflows/peril.yml

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jupiterone/dynamodb-dao",
"version": "1.8.0",
"version": "1.9.0",
"description": "DynamoDB Data Access Object (DAO) helper library",
"repository": {
"type": "git",
Expand Down
1 change: 0 additions & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export const DEFAULT_QUERY_LIMIT = 50;
export const MAX_BATCH_OPERATIONS = 25;
export const DEFAULT_LOCK_INCREMENT = 1;
3 changes: 0 additions & 3 deletions src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as AWS from 'aws-sdk';
import { v4 as uuid } from 'uuid';
import DynamoDbDao from '.';
import mockLogger from '../test/helpers/mockLogger';
import { DEFAULT_QUERY_LIMIT } from './constants';
import { CountOutput } from './types';
import { generateUpdateParams } from './update/generateUpdateParams';

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

expect(documentClient.scan).toHaveBeenCalledWith({
ConsistentRead: true,
Limit: 50,
TableName: tableName,
});
});
Expand Down
15 changes: 7 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ import { sleep } from '@lifeomic/attempt';
import { DocumentClient } from 'aws-sdk/clients/dynamodb';
import chunk from 'lodash.chunk';
import pMap from 'p-map';
import {
DEFAULT_LOCK_INCREMENT,
DEFAULT_QUERY_LIMIT,
MAX_BATCH_OPERATIONS,
} from './constants';
import { DEFAULT_LOCK_INCREMENT, MAX_BATCH_OPERATIONS } from './constants';
import { buildOptimisticLockOptions } from './locking/buildOptimisticLockOptions';
import {
decodeQueryUntilLimitCursor,
Expand Down Expand Up @@ -181,7 +177,10 @@ export default class DynamoDbDao<DataModel, KeySchema> {

// If the version attribute is supplied, increment it, otherwise only
// set the default if directed to do so
if (versionAttribute in data && !isNaN(dataAsMap[versionAttribute])) {
if (
versionAttribute in dataAsMap &&
!isNaN(dataAsMap[versionAttribute])
) {
dataAsMap[versionAttribute] += DEFAULT_LOCK_INCREMENT;
} else if (this.autoInitiateLockingAttribute) {
dataAsMap[versionAttribute] = DEFAULT_LOCK_INCREMENT;
Expand Down Expand Up @@ -354,7 +353,7 @@ export default class DynamoDbDao<DataModel, KeySchema> {
scanIndexForward,
keyConditionExpression,
filterExpression,
limit = DEFAULT_QUERY_LIMIT,
limit,
consistentRead,
} = input;

Expand Down Expand Up @@ -475,7 +474,7 @@ export default class DynamoDbDao<DataModel, KeySchema> {
filterExpression,
segment,
totalSegments,
limit = DEFAULT_QUERY_LIMIT,
limit,
consistentRead,
} = input;

Expand Down

0 comments on commit 06d9f7e

Please sign in to comment.