swc/bundler/tests/.cache/deno/e12f197f584c32e84c4a91178e294941eaa27f33.ts
강동윤 bbaf619f63
fix(bundler): Fix bugs (#1437)
swc_bundler:
 - [x] Fix wrapped esms. (denoland/deno#9307)
 - [x] Make test secure.
2021-03-02 17:33:03 +09:00

42 lines
1.0 KiB
TypeScript

// Loaded from https://deno.land/x/mongo@v0.20.0/src/collection/commands/aggregate.ts
import { CommandCursor } from "../../protocol/cursor.ts";
import { WireProtocol } from "../../protocol/protocol.ts";
import { AggregateOptions, Document } from "../../types.ts";
interface AggregateCursorContext {
dbName: string;
collectionName: string;
protocol: WireProtocol;
pipeline: Document;
options?: AggregateOptions;
}
export class AggregateCursor<T> extends CommandCursor<T> {
#context: AggregateCursorContext;
private async executor() {
const { dbName, pipeline, collectionName, protocol, options } =
this.#context;
const { cursor } = await protocol.commandSingle(dbName, {
aggregate: collectionName,
pipeline,
cursor: {
batchSize: options?.batchSize || 1000,
},
...options,
});
return {
...cursor,
id: cursor.id.toString(),
};
}
constructor(context: AggregateCursorContext) {
super(context.protocol, () => this.executor());
this.#context = context;
}
}