diff --git a/packages/service-provider-core/src/all-transport-types.ts b/packages/service-provider-core/src/all-transport-types.ts index 59cde5916e..9b589979b4 100644 --- a/packages/service-provider-core/src/all-transport-types.ts +++ b/packages/service-provider-core/src/all-transport-types.ts @@ -46,7 +46,6 @@ export type { ListCollectionsOptions, ListDatabasesOptions, ListIndexesOptions, - MapReduceOptions, MongoClientOptions, OrderedBulkOperation, ReadConcern, diff --git a/packages/service-provider-core/src/index.ts b/packages/service-provider-core/src/index.ts index 16aeb96893..220456455a 100644 --- a/packages/service-provider-core/src/index.ts +++ b/packages/service-provider-core/src/index.ts @@ -26,6 +26,8 @@ import ShellAuthOptions from './shell-auth-options'; export * from './all-transport-types'; export * from './all-fle-types'; +export { MapReduceOptions, FinalizeFunction } from './map-reduce-options'; + const bson = { ObjectId, DBRef, diff --git a/packages/service-provider-core/src/map-reduce-options.ts b/packages/service-provider-core/src/map-reduce-options.ts new file mode 100644 index 0000000000..6c9fbf74ab --- /dev/null +++ b/packages/service-provider-core/src/map-reduce-options.ts @@ -0,0 +1,30 @@ +import type { CommandOperationOptions, Document, ObjectId, Sort } from 'mongodb'; + +export type FinalizeFunction = ( + key: TKey, + reducedValue: TValue +) => TValue; + +export interface MapReduceOptions + extends CommandOperationOptions { + /** Sets the output target for the map reduce job. */ + out?: 'inline' | { inline: 1 } | { replace: string } | { merge: string } | { reduce: string }; + /** Query filter object. */ + query?: Document; + /** Sorts the input objects using this key. Useful for optimization, like sorting by the emit key for fewer reduces. */ + sort?: Sort; + /** Number of objects to return from collection. */ + limit?: number; + /** Keep temporary data. */ + keeptemp?: boolean; + /** Finalize function. */ + finalize?: FinalizeFunction | string; + /** Can pass in variables that can be access from map/reduce/finalize. */ + scope?: Document; + /** It is possible to make the execution stay in JS. Provided in MongoDB \> 2.0.X. */ + jsMode?: boolean; + /** Provide statistics on job execution time. */ + verbose?: boolean; + /** Allow driver to bypass schema validation in MongoDB 3.2 or higher. */ + bypassDocumentValidation?: boolean; +}