Skip to content

Commit 083f9b7

Browse files
Merge pull request #236 from shiftcode/#230-consistent-read-option-read-many
feat(read-many.request): consistentRead support for query/scan
2 parents 1edd5c9 + 026130a commit 083f9b7

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,22 @@ describe('ReadManyRequest', () => {
108108
})
109109
})
110110

111+
describe('consistentRead', () => {
112+
beforeEach(() => {
113+
request = new TestRequest(SimpleWithCompositePartitionKeyModel)
114+
})
115+
116+
it('should set param for consistent read', () => {
117+
request.consistentRead(true)
118+
expect(request.params.ConsistentRead).toBe(true)
119+
})
120+
121+
it('should return instance', () => {
122+
const r = request.consistentRead(true)
123+
expect(r).toBe(request)
124+
})
125+
})
126+
111127
describe('conditions functions', () => {
112128
beforeEach(() => {
113129
request = new TestRequest(SimpleWithPartitionKeyModel)

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,14 @@ export abstract class ReadManyRequest<
9898
return <any>this
9999
}
100100

101+
/**
102+
* Determines the read consistency model: If set to true, then the operation uses strongly consistent reads; otherwise, the operation uses eventually consistent reads.
103+
*/
104+
consistentRead(consistentRead: boolean = true): R {
105+
this.params.ConsistentRead = consistentRead
106+
return <any>this
107+
}
108+
101109
/**
102110
* add a condition for propertyPath
103111
* @example req.whereAttribute('path.to.prop').eq('value')

0 commit comments

Comments
 (0)