Utility functions for MongoDB Atlas with Node.js TypeScript setup. Version 1.0.30 stable release; low cadence. Provides convenience wrappers for MongoDB operations (connect, get all docs, drop collection, insert many, get compiled model) using Mongoose. Designed for TypeScript projects, relies on environment variables for credentials. Differentiator: simple, opinionated helper functions compared to using raw Mongoose.
npm install mongodb-utilityNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Connects to MongoDB, compiles a model, retrieves documents, inserts many, then drops collection.
Set the environment variables before calling any function. Use dotenv or similar.
Call getCompiledModel first to get the model, then pass it to getAllDocs.
Provide the string name of the collection, not the Mongoose model.
Consider using a more maintained library like mongoose directly for production.
Set MONGO_USER, MONGO_PASSWORD, MONGO_PATH environment variables before running the script.
Use `import { getAllDocs } from 'mongodb-utility'` instead of default import.Run `npm install mongodb-utility` and ensure tsconfig.json includes this package in `node_modules`.