File tree Expand file tree Collapse file tree 2 files changed +19
-8
lines changed Expand file tree Collapse file tree 2 files changed +19
-8
lines changed Original file line number Diff line number Diff line change @@ -14,17 +14,22 @@ import defaults from '../../defaults';
14
14
export class GridFSBucketAdapter extends FilesAdapter {
15
15
_databaseURI : string ;
16
16
_connectionPromise : Promise < Db > ;
17
+ _mongoOptions : Object ;
17
18
18
- constructor ( mongoDatabaseURI = defaults . DefaultMongoURI ) {
19
+ constructor ( mongoDatabaseURI = defaults . DefaultMongoURI , mongoOptions = { } ) {
19
20
super ( ) ;
20
21
this . _databaseURI = mongoDatabaseURI ;
22
+
23
+ const defaultMongoOptions = { useNewUrlParser : true } ;
24
+ this . _mongoOptions = Object . assign ( defaultMongoOptions , mongoOptions ) ;
21
25
}
22
26
23
27
_connect ( ) {
24
28
if ( ! this . _connectionPromise ) {
25
- this . _connectionPromise = MongoClient . connect ( this . _databaseURI ) . then (
26
- client => client . db ( client . s . options . dbName )
27
- ) ;
29
+ this . _connectionPromise = MongoClient . connect (
30
+ this . _databaseURI ,
31
+ this . _mongoOptions
32
+ ) . then ( client => client . db ( client . s . options . dbName ) ) ;
28
33
}
29
34
return this . _connectionPromise ;
30
35
}
Original file line number Diff line number Diff line change 2
2
GridStoreAdapter
3
3
Stores files in Mongo using GridStore
4
4
Requires the database adapter to be based on mongoclient
5
+ (GridStore is deprecated, Please use GridFSBucket instead)
5
6
6
7
@flow weak
7
8
*/
@@ -14,17 +15,22 @@ import defaults from '../../defaults';
14
15
export class GridStoreAdapter extends FilesAdapter {
15
16
_databaseURI : string ;
16
17
_connectionPromise : Promise < Db > ;
18
+ _mongoOptions : Object ;
17
19
18
- constructor ( mongoDatabaseURI = defaults . DefaultMongoURI ) {
20
+ constructor ( mongoDatabaseURI = defaults . DefaultMongoURI , mongoOptions = { } ) {
19
21
super ( ) ;
20
22
this . _databaseURI = mongoDatabaseURI ;
23
+
24
+ const defaultMongoOptions = { useNewUrlParser : true } ;
25
+ this . _mongoOptions = Object . assign ( defaultMongoOptions , mongoOptions ) ;
21
26
}
22
27
23
28
_connect ( ) {
24
29
if ( ! this . _connectionPromise ) {
25
- this . _connectionPromise = MongoClient . connect ( this . _databaseURI ) . then (
26
- client => client . db ( client . s . options . dbName )
27
- ) ;
30
+ this . _connectionPromise = MongoClient . connect (
31
+ this . _databaseURI ,
32
+ this . _mongoOptions
33
+ ) . then ( client => client . db ( client . s . options . dbName ) ) ;
28
34
}
29
35
return this . _connectionPromise ;
30
36
}
You can’t perform that action at this time.
0 commit comments