Skip to content

Commit

Permalink
Merge pull request #236 from shiftcode/#230-consistent-read-option-re…
Browse files Browse the repository at this point in the history
…ad-many

feat(read-many.request): consistentRead support for query/scan
  • Loading branch information
michaelwittwer authored Sep 17, 2019
2 parents 1edd5c9 + 026130a commit 083f9b7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/dynamo/request/read-many.request.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,22 @@ describe('ReadManyRequest', () => {
})
})

describe('consistentRead', () => {
beforeEach(() => {
request = new TestRequest(SimpleWithCompositePartitionKeyModel)
})

it('should set param for consistent read', () => {
request.consistentRead(true)
expect(request.params.ConsistentRead).toBe(true)
})

it('should return instance', () => {
const r = request.consistentRead(true)
expect(r).toBe(request)
})
})

describe('conditions functions', () => {
beforeEach(() => {
request = new TestRequest(SimpleWithPartitionKeyModel)
Expand Down
8 changes: 8 additions & 0 deletions src/dynamo/request/read-many.request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ export abstract class ReadManyRequest<
return <any>this
}

/**
* Determines the read consistency model: If set to true, then the operation uses strongly consistent reads; otherwise, the operation uses eventually consistent reads.
*/
consistentRead(consistentRead: boolean = true): R {
this.params.ConsistentRead = consistentRead
return <any>this
}

/**
* add a condition for propertyPath
* @example req.whereAttribute('path.to.prop').eq('value')
Expand Down

0 comments on commit 083f9b7

Please sign in to comment.