Update DB URI Parsing from CLI Params to Allow mongoDB+srv protocol
See original GitHub issueI am deploying a Mongo instance using Mongo Atlas. In one of the newer driver versions, a new protocol was added to allow connecting to a Mongo cluster without having to specify all hosts in the cluster. Details may be found in the MongoDB 3.6 docs. The mongo-seeding-cli
works fine with the new protocol if the user specifies the connection address using a DB URI string. However, the user is unable to specify individual parameters using the new service because the core mongo seeding library automatically adds a port to the connection string, which is not allowed when connecting to mongo using the mongo+srv
protocol.
mongo-seeding Connecting to mongodb+srv://<myAdmin>:<myPassword>@runewordfinder-0ltsc.mongodb.net:27017/runewordfinder... +9ms
(node:73572) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.
mongo-seeding Ports not accepted with `mongodb+srv` URIs
I would like to be able to specify the individual parameters so I may hide my password as an environment variable. I propose that core/src/database/database-connector.ts#getDbConnectionUri(...)
is updated to check the provided protocol and create an appropriate string that:
- Includes the port if
protocol === 'mongodb'
- Does not include the port if
protocol === 'mongodb+srv'
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (5 by maintainers)
@BenedictRasmussen here it is! https://github.com/pkosiec/mongo-seeding/releases/tag/v3.1.1 🚀
@BenedictRasmussen Sure thing - I’m going to update dependencies and then I will publish new release 🙂It should arrive in next 2 hours.