Skip to content

Commit

Permalink
chore: Revert "fix(generators): Harden mongodb.js to reliably extract…
Browse files Browse the repository at this point in the history
… database from any connection string (#3264)"

This reverts commit 7b0f82c.
  • Loading branch information
daffl committed Jan 5, 2024
1 parent 7b0f82c commit a74f66a
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions packages/generators/src/connection/templates/mongodb.tpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,10 @@ declare module './declarations' {
export const ${database} = (app: Application) => {
const connection = app.get('${database}') as string
const databaseRegex = /\/([a-zA-Z0-9_\\-]+)(?:\?|$)/;
const databaseName = databaseRegex.exec(connection)?.[1];
const database = new URL(connection).pathname.substring(1)
const mongoClient = MongoClient.connect(connection)
.then(client => client.db(databaseName));
.then(client => client.db(database))
app.set('${database}Client', mongoClient)
}
`
Expand Down

0 comments on commit a74f66a

Please sign in to comment.