UNPKG

@notross/mongo-singleton

Version:

A lightweight, zero-fuss way to get a single shared MongoDB connection across your Node.js codebase.

11 lines 456 B
import 'dotenv/config'; import { mongoClient } from '.'; const uri = process.env.MONGO_CONNECTION_STRING; mongoClient.init({ connection: uri, database: 'roc-sync' }); async function getUserByEmail(email) { console.log(`Finding user with email ${email}`); const user = await mongoClient.collection('users').findOne({ email }); console.log(`⚡️ found user`, user); } getUserByEmail('rosslibbyatx@gmail.com'); //# sourceMappingURL=client.js.map