diff --git a/packages/i18n/src/locales/en_US.js b/packages/i18n/src/locales/en_US.js index 339126ba17..f0c26cfc25 100644 --- a/packages/i18n/src/locales/en_US.js +++ b/packages/i18n/src/locales/en_US.js @@ -676,6 +676,10 @@ const translations = { description: 'Specifies a cumulative time limit in milliseconds for processing operations on a cursor.', example: 'db.collection.find(query, projection).maxTimeMS(timeLimit)' }, + maxAwaitTimeMS: { + description: 'Set a maxAwaitTimeMS on a tailing cursor query to allow to customize the timeout value for the option awaitData (Only supported on MongoDB 3.2 or higher, ignored otherwise)', + example: 'db.collection.find(query, projection).maxAwaitTimeMS(timeLimit)' + }, min: { link: 'https://docs.mongodb.com/manual/reference/method/cursor.min', description: 'Specifies the inclusive lower bound for a specific index in order to constrain the results of find(). min() provides a way to specify lower bounds on compound key indexes.', diff --git a/packages/service-provider-core/src/cursor.ts b/packages/service-provider-core/src/cursor.ts index 609edae74d..1c002f0ba0 100644 --- a/packages/service-provider-core/src/cursor.ts +++ b/packages/service-provider-core/src/cursor.ts @@ -171,6 +171,15 @@ export default interface ServiceProviderCursor { */ maxTimeMS(value: number): ServiceProviderCursor; + /** + * Set the maxAwaitTimeMS value. + * + * @param {number} The maxAwaitTimeMS value. + * + * @returns {ServiceProviderCursor} The cursor. + */ + maxAwaitTimeMS(value: number): ServiceProviderCursor; + /** * Set the min index bounds. * diff --git a/packages/shell-api/src/cursor.spec.ts b/packages/shell-api/src/cursor.spec.ts index 5f42211382..da5a6c5b35 100644 --- a/packages/shell-api/src/cursor.spec.ts +++ b/packages/shell-api/src/cursor.spec.ts @@ -347,6 +347,26 @@ describe('Cursor', () => { }); }); + describe('#maxAwaitTimeMS', () => { + let spCursor: SinonStubbedInstance; + let shellApiCursor; + let mock; + const value = 5000; + + beforeEach(() => { + mock = sinon.mock().withArgs(value); + spCursor = sinon.createStubInstance(ServiceProviderCursor, { + maxAwaitTimeMS: mock + }); + shellApiCursor = new Cursor(mongo, spCursor); + }); + + it('fluidly sets maxAwaitTimeMS', () => { + expect(shellApiCursor.maxAwaitTimeMS(value)).to.equal(shellApiCursor); + mock.verify(); + }); + }); + describe('#min', () => { let spCursor: SinonStubbedInstance; let shellApiCursor; diff --git a/packages/shell-api/src/cursor.ts b/packages/shell-api/src/cursor.ts index a5190c7ae9..de785a7800 100644 --- a/packages/shell-api/src/cursor.ts +++ b/packages/shell-api/src/cursor.ts @@ -207,6 +207,13 @@ export default class Cursor extends ShellApiClass { return this; } + @returnType('Cursor') + @serverVersions(['3.2.0', ServerVersions.latest]) + maxAwaitTimeMS(value: number): Cursor { + this._cursor.maxAwaitTimeMS(value); + return this; + } + @returnType('Cursor') min(indexBounds: Document): Cursor { this._cursor.min(indexBounds);