Skip to content

Commit 001c1d0

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

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/shell-api/src/collection.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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)