Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/i18n/src/locales/en_US.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
Expand Down
9 changes: 9 additions & 0 deletions packages/service-provider-core/src/cursor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
20 changes: 20 additions & 0 deletions packages/shell-api/src/cursor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,26 @@ describe('Cursor', () => {
});
});

describe('#maxAwaitTimeMS', () => {
let spCursor: SinonStubbedInstance<ServiceProviderCursor>;
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<ServiceProviderCursor>;
let shellApiCursor;
Expand Down
7 changes: 7 additions & 0 deletions packages/shell-api/src/cursor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down