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
2 changes: 1 addition & 1 deletion src/cursor/aggregation_cursor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export class AggregationCursor<TSchema = Document> extends AbstractCursor<TSchem
}

/** Add an out stage to the aggregation pipeline */
out($out: string): this {
out($out: { db: string; coll: string } | string): this {
assertUninitialized(this);
this[kPipeline].push({ $out });
return this;
Expand Down
10 changes: 8 additions & 2 deletions test/types/mongodb.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,11 @@ expectType<string | null>(await composedMap.next());
expectType<string[]>(await composedMap.toArray());

const builtCursor = coll.aggregate();
expectType<AggregationCursor<Document>>(builtCursor.out('string')); // should allow string values for the out helper
expectError(builtCursor.out(1)); // should error on non-string values
// should allow string values for the out helper
expectType<AggregationCursor<Document>>(builtCursor.out('collection'));
// should also allow an object specifying db/coll (as of MongoDB 4.4)
expectType<AggregationCursor<Document>>(builtCursor.out({ db: 'db', coll: 'collection' }));
// should error on other object shapes
expectError(builtCursor.out({ other: 'shape' }));
// should error on non-object, non-string values
expectError(builtCursor.out(1));