Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix(cli): Update MongoDB connection string for node 17+ #2875

Merged
merged 1 commit into from
Nov 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/api/databases/mongodb.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ There are two typical setup steps for using `@feathersjs/mongodb` in an applicat

### Connect to the Database

Before using `@feathersjs/mongodb`, you'll need to create a connection to the database. This example connects to a MongoDB database similar to how the CLI-generated app connects. It uses `app.get('mongodb')` to read the connection string from `@feathersjs/configuration`. The connection string would be something similar to `mongodb://localhost:27017/my-app-dev` for local development or one provided by your database host.
Before using `@feathersjs/mongodb`, you'll need to create a connection to the database. This example connects to a MongoDB database similar to how the CLI-generated app connects. It uses `app.get('mongodb')` to read the connection string from `@feathersjs/configuration`. The connection string would be something similar to `mongodb://127.0.0.1:27017/my-app-dev` for local development or one provided by your database host.

Once the connection attempt has been started, the code uses `app.set('monodbClient', mongoClient)` to store the connection promise back into the config, which allows it to be looked up when initializing individual services.

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/connection/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export type ConnectionGeneratorArguments = FeathersBaseContext &

export const defaultConnectionString = (type: DatabaseType, name: string) => {
const connectionStrings = {
mongodb: `mongodb://localhost:27017/${name}`,
mongodb: `mongodb://127.0.0.1:27017/${name}`,
mysql: `mysql://root:@localhost:3306/${name}`,
postgresql: `postgres://postgres:@localhost:5432/${name}`,
sqlite: `${name}.sqlite`,
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/test/generators.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ describe('@feathersjs/cli', () => {
{
dependencyVersions,
database: 'mongodb' as const,
connectionString: `mongodb://localhost:27017/${name}`
connectionString: `mongodb://127.0.0.1:27017/${name}`
},
{ cwd }
)
Expand Down