Skip to content

Commit

Permalink
Add check comments to db.ts file
Browse files Browse the repository at this point in the history
  • Loading branch information
lokeshwar777 committed Apr 21, 2024
1 parent df129d9 commit 6980bef
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import { checkReplicaSet } from "./utilities/checkReplicaSet";
let session!: mongoose.ClientSession;

export const connect = async (dbName?: string): Promise<void> => {
// firstly we check if a connection to the database already exists.
if (mongoose.connection.readyState !== 0) {
// if the connection state is not 0, it means a connection already exists so we return.
return;
}

// if no connection exists, we try to establish a new connection.
try {
await mongoose.connect(MONGO_DB_URL as string, {
dbName,
Expand Down

0 comments on commit 6980bef

Please sign in to comment.