Skip to content

Commit 7e97c85

Browse files
Merge pull request #190 from shiftcode/#189-remove-default-limit
#189 remove default limit
2 parents 99c7534 + 884c13b commit 7e97c85

File tree

7 files changed

+11
-17
lines changed

7 files changed

+11
-17
lines changed

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ personStore
4343
- [typescript-library-starter](https://github.com/alexjoverm/typescript-library-starter) - Starter project which helps creating a TypeScript library project
4444
- [vogels](https://github.com/ryanfitz/vogels) - To get an idea on how to build the fluent api
4545
- [typestore](http://densebrain.github.io/typestore/) - Inspiration on how to implement the model decorators
46-
- [BrowserStack](https://www.browserstack.com) - We use BrowserStack to verify everything works as expected
47-
![BrowserStack](https://github.com/shiftcode/dynamo-easy/browserstack-logo.png)
4846

4947
## Contributors
5048
Made with :heart: by [@michaelwittwer](https://github.com/michaelwittwer) and all these wonderful contributors ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)):

browserstack-logo.png

-31 KB
Binary file not shown.

src/dynamo/request/query/query.request.spec.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { DynamoDbWrapper } from '../../dynamo-db-wrapper'
1818
import { attribute } from '../../expression/logical-operator/attribute.function'
1919
import { ReadManyRequest } from '../read-many.request'
2020
import { QueryRequest } from './query.request'
21+
import * as DynamoDB from 'aws-sdk/clients/dynamodb'
2122

2223
describe('query request', () => {
2324
let querySpy: jasmine.Spy
@@ -60,9 +61,7 @@ describe('query request', () => {
6061
})
6162

6263
it('defaults should be defined', () => {
63-
expect(request.params.TableName).toBe('complex_model')
64-
expect(request.params.Limit).toBe(QueryRequest.DEFAULT_LIMIT)
65-
expect(Object.keys(request.params).length).toBe(2)
64+
expect(request.params).toEqual(<DynamoDB.QueryInput>{ TableName: 'complex_model' })
6665
})
6766

6867
it('Limit', () => {

src/dynamo/request/read-many.request.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ describe('ReadManyRequest', () => {
3535
beforeEach(() => {
3636
request = new TestRequest(SimpleWithPartitionKeyModel)
3737
})
38-
it('should set the default limit to params', () => {
39-
expect(request.params).toBeDefined()
40-
expect(request.params.Limit).toBe(ReadManyRequest.DEFAULT_LIMIT)
38+
39+
it('should set the default params', () => {
40+
expect(request.params).toEqual({ TableName: getTableName(SimpleWithPartitionKeyModel) })
4141
})
4242
})
4343

@@ -172,7 +172,7 @@ describe('ReadManyRequest', () => {
172172

173173
it('execSingle should not alter request params', async () => {
174174
await request.execSingle()
175-
expect(request.params.Limit).toBe(ReadManyRequest.DEFAULT_LIMIT)
175+
expect(request.params.Limit).toBeUndefined()
176176
})
177177

178178
it('execSingle empty response', async () => {

src/dynamo/request/read-many.request.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ export abstract class ReadManyRequest<T,
3232
O extends DynamoDB.QueryOutput | DynamoDB.ScanOutput,
3333
Z extends QueryResponse<T> | ScanResponse<T>,
3434
R extends QueryRequest<T> | ScanRequest<T>> extends StandardRequest<T, I, ReadManyRequest<T, I, O, Z, R>> {
35-
static DEFAULT_LIMIT = 10
35+
36+
/** Infinite limit will remove the Limit param from request params when calling ReadManyRequest.limit(ReadManyRequest.INFINITE_LIMIT) */
3637
static INFINITE_LIMIT = -1
3738

3839
protected secondaryIndex?: SecondaryIndex<T>
@@ -46,7 +47,6 @@ export abstract class ReadManyRequest<T,
4647

4748
protected constructor(dynamoDBWrapper: DynamoDbWrapper, modelClazz: ModelConstructor<T>) {
4849
super(dynamoDBWrapper, modelClazz)
49-
this.limit(ReadManyRequest.DEFAULT_LIMIT)
5050
}
5151

5252
/**

src/dynamo/request/scan/scan.request.spec.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,7 @@ describe('scan request', () => {
2828
})
2929

3030
it('default params', () => {
31-
const params: DynamoDB.ScanInput = request.params
32-
expect(params.TableName).toBe('complex_model')
33-
expect(params.Limit).toBe(ReadManyRequest.DEFAULT_LIMIT)
34-
expect(Object.keys(params).length).toBe(2)
31+
expect(request.params).toEqual(<DynamoDB.ScanInput>{ TableName: 'complex_model' })
3532
})
3633

3734
it('execSingle', async () => {

src/dynamo/request/standard.request.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ describe('StandardRequest', () => {
1818
}
1919
}
2020

21-
it('adds table name to params', () => {
21+
it('creates default params with table name', () => {
2222
const msr = new MyStandardRequest(Organization)
23-
expect(msr.params.TableName).toEqual(getTableName(Organization))
23+
expect(msr.params).toEqual({ TableName: getTableName(Organization) })
2424
})
2525
})

0 commit comments

Comments
 (0)