Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
112 lines (68 sloc) 3.25 KB
.. include:: /includes/unicode-checkmark.rst
MongoDB Node.js Driver
.. default-domain:: mongodb
.. contents:: On this page
:backlinks: none
:depth: 1
:class: twocols
The official MongoDB Node.js driver provides both callback-based and Promise-based
interaction with MongoDB, allowing applications to take full advantage of the new
features in ES6. The 2.x series of the driver is powered by a brand new core
driver and BSON library.
- `Tutorials <>`__
- `Usage Guide <>`__
- `API Reference <>`_
- `Changelog <>`__
- `Source Code <>`__
Take the free online course taught by MongoDB
.. list-table::
* - .. cssclass:: bordered-figure
.. figure:: /figures/M220JS_hero.jpg
- `M220JS: MongoDB for JavaScript Developers <>`__
Learn the essentials of Node.js application development with MongoDB.
The recommended way to get started using the Node.js 2.0 driver is by using
`NPM (Node Package Manager) <>`__ to install the dependency in your project.
After you’ve created your project with ``npm init``, you can install the MongoDB driver and its dependencies
with the command:
.. code-block:: sh
npm install mongodb --save
This will download the MongoDB driver and add a dependency entry in your package.json file.
Connect to MongoDB Atlas
To connect to a `MongoDB Atlas <>`_ cluster, use the
`Atlas connection string <>`__ for your cluster:
.. code-block:: javascript
const MongoClient = require('mongodb').MongoClient;
const uri = "mongodb+srv://<username>:<password>@<your-cluster-url>/test?retryWrites=true&w=majority";
const client = new MongoClient(uri, { useNewUrlParser: true });
client.connect(err => {
const collection = client.db("test").collection("devices");
// perform actions on the collection object
See `Connect to MongoDB <>`__
for more ways to connect.
MongoDB Compatibility
.. include:: /includes/mongodb-compatibility-table-node.rst
.. include:: /includes/older-server-versions-unsupported.rst
Language Compatibility
.. include:: /includes/extracts/node-driver-compatibility-matrix-language.rst
.. include:: /includes/language-compatibility-table-node.rst
How to get help
- Join our `Google Group <>`__.
- Ask on `Stack Overflow <>`__.
- Visit our `Support Channels <>`__.
- See `Issues & Help <>`__.
You can’t perform that action at this time.