
Product
Secure Your AI-Generated Code with Socket MCP
Socket MCP brings real-time security checks to AI-generated code, helping developers catch risky dependencies before they enter the codebase.
simple-mongodb
Advanced tools
A simple lib to simplify your work of using mongoldb native driver in node.js.
A simple lib to simplify your work of using mongoldb native driver in node.js.
npm install --save simple-mongodb
First, you should connect the mongodb when app starts:
import DB from 'simple-mongodb';
DB.connect(url);
The connect()
method is asynchronous. It will return a Promise, so you can use it like:
DB.connect(url)
.then(db => {
// db is the instance of connected database.
})
.catch(err => console.log(err));
or:
async function() {
try {
const db = await DB.connect(url);
} catch (err) {
console.log(err);
}
}
Once the mongodb is connected, you could use it anywhere in your code like this:
DB.find(collectionName, args);
The args
is an object whose propertoes arr correspond to the MongoDB Driver's arguments.
This method must be called before any other methods.
Close the db and it's underlying connections.
The force
argument is default to false
.
Inserts a single document into MongoDB.
FAQs
A simple lib to simplify your work of using mongoldb native driver in node.js.
The npm package simple-mongodb receives a total of 4 weekly downloads. As such, simple-mongodb popularity was classified as not popular.
We found that simple-mongodb demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket MCP brings real-time security checks to AI-generated code, helping developers catch risky dependencies before they enter the codebase.
Security News
As vulnerability data bottlenecks grow, the federal government is formally investigating NIST’s handling of the National Vulnerability Database.
Research
Security News
Socket’s Threat Research Team has uncovered 60 npm packages using post-install scripts to silently exfiltrate hostnames, IP addresses, DNS servers, and user directories to a Discord-controlled endpoint.