diff --git a/src/dynamo/request/read-many.request.spec.ts b/src/dynamo/request/read-many.request.spec.ts index 68ad6554d..5366df137 100644 --- a/src/dynamo/request/read-many.request.spec.ts +++ b/src/dynamo/request/read-many.request.spec.ts @@ -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) diff --git a/src/dynamo/request/read-many.request.ts b/src/dynamo/request/read-many.request.ts index df7160331..18bf42a8e 100644 --- a/src/dynamo/request/read-many.request.ts +++ b/src/dynamo/request/read-many.request.ts @@ -98,6 +98,14 @@ export abstract class ReadManyRequest< return 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 this + } + /** * add a condition for propertyPath * @example req.whereAttribute('path.to.prop').eq('value')