Applying CRUD operations with the low-level mongodb driver
Again, I won't cover installation of the server software. Please refer to the official installation instructions(https://docs.mongodb.com/manual/installation/) in order to get a MongoDB server up and running on your machine.
Note
If you have Docker installed on your machine, the quickest way to get a MongoDB server up and running is this one-liner:
docker run --rm --name mongo -p 27017:27017 -d mongo:3.4
See https://hub.docker.com/_/mongo/ for more details.
Once this is done, create a new project folder called mongodb-test
, and in there create an initial package.json
as follows:
{ "name": "mongodb-test", "version": "0.0.1", "description": "", "dependencies": { "mongodb": "^2.2.22" }, "devDependencies": {} }
As always, we pull in the dependencies with
npm install
Now we can create a first program in file index.js
:
'use strict'; var MongoClient = require('mongodb').MongoClient; MongoClient.connect( 'mongodb...