Skip to content

Commit b86ded0

Browse files
committed
add some options to the sample aggregate
1 parent 8b859ce commit b86ded0

File tree

1 file changed

+30
-26
lines changed

1 file changed

+30
-26
lines changed

packages/shell-api/src/collection.ts

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -48,30 +48,30 @@ import {
4848
onlyShardedCollectionsInConfigFilter,
4949
aggregateBackgroundOptionNotSupportedHelp,
5050
} from './helpers';
51-
import type {
52-
AnyBulkWriteOperation,
53-
BulkWriteOptions,
54-
CountOptions,
55-
CountDocumentsOptions,
56-
ChangeStreamOptions,
57-
CreateIndexesOptions,
58-
DeleteOptions,
59-
DistinctOptions,
60-
Document,
61-
EstimatedDocumentCountOptions,
62-
ExplainVerbosityLike,
63-
FindOneAndDeleteOptions,
64-
FindOneAndReplaceOptions,
65-
FindOneAndUpdateOptions,
66-
FindOptions,
67-
InsertOneOptions,
68-
ReplaceOptions,
69-
RunCommandOptions,
70-
UpdateOptions,
71-
DropCollectionOptions,
72-
CheckMetadataConsistencyOptions,
73-
AggregateOptions,
74-
SearchIndexDescription,
51+
import {
52+
type AnyBulkWriteOperation,
53+
type BulkWriteOptions,
54+
type CountOptions,
55+
type CountDocumentsOptions,
56+
type ChangeStreamOptions,
57+
type CreateIndexesOptions,
58+
type DeleteOptions,
59+
type DistinctOptions,
60+
type Document,
61+
type EstimatedDocumentCountOptions,
62+
type ExplainVerbosityLike,
63+
type FindOneAndDeleteOptions,
64+
type FindOneAndReplaceOptions,
65+
type FindOneAndUpdateOptions,
66+
type FindOptions,
67+
type InsertOneOptions,
68+
type ReplaceOptions,
69+
type RunCommandOptions,
70+
type UpdateOptions,
71+
type DropCollectionOptions,
72+
type CheckMetadataConsistencyOptions,
73+
type AggregateOptions,
74+
type SearchIndexDescription,
7575
} from '@mongosh/service-provider-core';
7676
import type { RunCommandCursor, Database, DatabaseWithSchema } from './index';
7777
import {
@@ -2389,7 +2389,7 @@ export class Collection<
23892389
): Promise<RunCommandCursor> {
23902390
this._emitCollectionApiCall('checkMetadataConsistency', { options });
23912391

2392-
return this._database._runCursorCommand({
2392+
return await this._database._runCursorCommand({
23932393
checkMetadataConsistency: this._name,
23942394
});
23952395
}
@@ -2531,7 +2531,11 @@ export class Collection<
25312531

25322532
async _getSampleDocs(): Promise<Document[]> {
25332533
this._cachedSampleDocs = await (
2534-
await this.aggregate([{ $sample: { size: 10 } }])
2534+
await this.aggregate([{ $sample: { size: 10 } }], {
2535+
allowDiskUse: true,
2536+
maxTimeMS: 1000,
2537+
readPreference: 'secondaryPreferred',
2538+
})
25352539
).toArray();
25362540
return this._cachedSampleDocs;
25372541
}

0 commit comments

Comments
 (0)