This is a basic wrapper around the MongoDB SDK with some simple static functions to interact with a Mongo Database.
- Create a MongoDB either locally or in the cloud.
- Create a .env file and set your MongoDB connection string.
MONGO_DB_CONNECTION_STRING=mongodb://localhost:27017
import {MongoDB} from "@xdapps/mongodb-utils"
const db = new MongoDB("database_name");
const collectionName = "users";
const searchCriteria = {email: "johnDoe@gmail.com"};
const docResult = await db.getSingleDocFromDb(collectionName, searchCriteria);