Add useNewUrlParser options to GridFSBucketAdapter (#5548)
* Add useNewUrlParser options to GridFSBucketAdapter * allow overriding default
This commit is contained in:
@@ -14,17 +14,22 @@ import defaults from '../../defaults';
|
||||
export class GridFSBucketAdapter extends FilesAdapter {
|
||||
_databaseURI: string;
|
||||
_connectionPromise: Promise<Db>;
|
||||
_mongoOptions: Object;
|
||||
|
||||
constructor(mongoDatabaseURI = defaults.DefaultMongoURI) {
|
||||
constructor(mongoDatabaseURI = defaults.DefaultMongoURI, mongoOptions = {}) {
|
||||
super();
|
||||
this._databaseURI = mongoDatabaseURI;
|
||||
|
||||
const defaultMongoOptions = { useNewUrlParser: true };
|
||||
this._mongoOptions = Object.assign(defaultMongoOptions, mongoOptions);
|
||||
}
|
||||
|
||||
_connect() {
|
||||
if (!this._connectionPromise) {
|
||||
this._connectionPromise = MongoClient.connect(this._databaseURI).then(
|
||||
client => client.db(client.s.options.dbName)
|
||||
);
|
||||
this._connectionPromise = MongoClient.connect(
|
||||
this._databaseURI,
|
||||
this._mongoOptions
|
||||
).then(client => client.db(client.s.options.dbName));
|
||||
}
|
||||
return this._connectionPromise;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
GridStoreAdapter
|
||||
Stores files in Mongo using GridStore
|
||||
Requires the database adapter to be based on mongoclient
|
||||
(GridStore is deprecated, Please use GridFSBucket instead)
|
||||
|
||||
@flow weak
|
||||
*/
|
||||
@@ -14,17 +15,22 @@ import defaults from '../../defaults';
|
||||
export class GridStoreAdapter extends FilesAdapter {
|
||||
_databaseURI: string;
|
||||
_connectionPromise: Promise<Db>;
|
||||
_mongoOptions: Object;
|
||||
|
||||
constructor(mongoDatabaseURI = defaults.DefaultMongoURI) {
|
||||
constructor(mongoDatabaseURI = defaults.DefaultMongoURI, mongoOptions = {}) {
|
||||
super();
|
||||
this._databaseURI = mongoDatabaseURI;
|
||||
|
||||
const defaultMongoOptions = { useNewUrlParser: true };
|
||||
this._mongoOptions = Object.assign(defaultMongoOptions, mongoOptions);
|
||||
}
|
||||
|
||||
_connect() {
|
||||
if (!this._connectionPromise) {
|
||||
this._connectionPromise = MongoClient.connect(this._databaseURI).then(
|
||||
client => client.db(client.s.options.dbName)
|
||||
);
|
||||
this._connectionPromise = MongoClient.connect(
|
||||
this._databaseURI,
|
||||
this._mongoOptions
|
||||
).then(client => client.db(client.s.options.dbName));
|
||||
}
|
||||
return this._connectionPromise;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user