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