Skip to content

Commit

Permalink
fix(cli): mongodb connection string for node 17+ (#2875)
Browse files Browse the repository at this point in the history
  • Loading branch information
marshallswain authored Nov 18, 2022
1 parent 0b7b7ba commit 7fa2012
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
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

0 comments on commit 7fa2012

Please # to comment.