Skip to content

Instantly share code, notes, and snippets.

View trybrito's full-sized avatar
🎯
Focused

Thiago Raniery Brito trybrito

🎯
Focused
View GitHub Profile
@manavm1990
manavm1990 / mongodb.js
Last active November 30, 2021 11:19
Create connection to mongodb and keep alive until server shut down.
// Loads a reusable Mongo client for the application.
import { MongoClient } from "mongodb";
// TODO: Check that your path is correct if using a config file (which you should)
import config from "../../config.js";
// TODO: Check that your config file is exporting out an object with properties used in the next line.
const client = new MongoClient(config.db.clientURL);
client