@@ -12,13 +12,19 @@ const {
1212 makeLegacyListCollectionsCursor,
1313 makeLegacyListIndexesCursor
1414} = require ( './legacy_wrappers/cursors' ) ;
15- const { makeLegacyGridFSBucket } = require ( './legacy_wrappers/gridfs' ) ;
15+ const {
16+ makeLegacyGridFSBucket,
17+ makeLegacyGridFSBucketWriteStream
18+ } = require ( './legacy_wrappers/gridfs' ) ;
1619const { makeLegacyChangeStream } = require ( './legacy_wrappers/change_stream' ) ;
1720const { makeLegacyClientSession } = require ( './legacy_wrappers/session' ) ;
21+ const {
22+ makeLegacyUnorderedBulkOperation,
23+ makeLegacyOrderedBulkOperation
24+ } = require ( './legacy_wrappers/bulk' ) ;
1825
1926/** @type {import('..') } */
2027module . exports = Object . create ( null ) ;
21-
2228Object . defineProperty ( module . exports , '__esModule' , { value : true } ) ;
2329
2430const classesWithAsyncAPIs = new Map ( [
@@ -32,9 +38,26 @@ const classesWithAsyncAPIs = new Map([
3238 [ 'Db' , makeLegacyDb ] ,
3339 [ 'GridFSBucket' , makeLegacyGridFSBucket ] ,
3440 [ 'ClientSession' , makeLegacyClientSession ] ,
35- [ 'MongoClient' , makeLegacyMongoClient ]
41+ [ 'MongoClient' , makeLegacyMongoClient ] ,
42+
43+ // Need to be exported top-level still
44+ [ 'ClientSession' , makeLegacyClientSession ] ,
45+ [ 'GridFSBucketWriteStream' , makeLegacyGridFSBucketWriteStream ] ,
46+ [ 'OrderedBulkOperation' , makeLegacyOrderedBulkOperation ] ,
47+ [ 'UnorderedBulkOperation' , makeLegacyUnorderedBulkOperation ]
3648] ) ;
3749
50+ const TODO_SPECIAL_IMPORTS = new Map ( [
51+ [ 'ClientSession' , '/lib/sessions' ] ,
52+ [ 'GridFSBucketWriteStream' , '/lib/gridfs/upload' ] ,
53+ [ 'OrderedBulkOperation' , '/lib/bulk/ordered' ] ,
54+ [ 'UnorderedBulkOperation' , '/lib/bulk/unordered' ]
55+ ] ) ;
56+
57+ for ( const [ missingTopLevelClassName , location ] of TODO_SPECIAL_IMPORTS ) {
58+ mongodb [ missingTopLevelClassName ] = require ( `mongodb${ location } ` ) [ missingTopLevelClassName ] ;
59+ }
60+
3861for ( const [ mongodbExportName , mongodbExportValue ] of Object . entries ( mongodb ) ) {
3962 let makeLegacyClass = classesWithAsyncAPIs . get ( mongodbExportName ) ;
4063 if ( makeLegacyClass != null ) {
0 commit comments