Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mongodb-core

Package Overview
Dependencies
Maintainers
1
Versions
177
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongodb-core

Core MongoDB driver functionality, no bells and whistles and meant for integration not end applications

  • 1.1.7
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
134K
decreased by-34.8%
Maintainers
1
Weekly downloads
 
Created

What is mongodb-core?

The mongodb-core package is a low-level driver for MongoDB that provides the core functionality for interacting with MongoDB databases. It is used internally by the higher-level mongodb package but can be used directly for more fine-grained control over MongoDB operations.

What are mongodb-core's main functionalities?

Connecting to MongoDB

This feature allows you to establish a connection to a MongoDB server. The code sample demonstrates how to create a new MongoClient instance and connect to a MongoDB server running on localhost.

const MongoClient = require('mongodb-core').MongoClient;
const client = new MongoClient('mongodb://localhost:27017');
client.connect((err) => {
  if (err) throw err;
  console.log('Connected to MongoDB');
  client.close();
});

Performing CRUD Operations

This feature allows you to perform CRUD (Create, Read, Update, Delete) operations on a MongoDB database. The code sample demonstrates how to insert a document into a collection.

const MongoClient = require('mongodb-core').MongoClient;
const client = new MongoClient('mongodb://localhost:27017');
client.connect((err) => {
  if (err) throw err;
  const db = client.db('test');
  const collection = db.collection('documents');
  collection.insertOne({ a: 1 }, (err, result) => {
    if (err) throw err;
    console.log('Document inserted');
    client.close();
  });
});

Handling Replication

This feature allows you to handle MongoDB replication. The code sample demonstrates how to connect to a MongoDB replica set.

const ReplSet = require('mongodb-core').ReplSet;
const replSet = new ReplSet([{ host: 'localhost', port: 27017 }], { setName: 'rs0' });
replSet.on('connect', () => {
  console.log('Connected to replica set');
  replSet.destroy();
});
replSet.connect();

Other packages similar to mongodb-core

Keywords

FAQs

Package last updated on 18 Dec 2014

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc