June 2014
Intermediate to advanced
696 pages
38h 52m
English
To illustrate the process of creating, listing, and deleting collections, Listing 13.5 makes a series of chained callbacks that list the collections, create a new collection, and then delete the new collection. The code is very basic and easy to follow. Figure 13.5 shows the output.
Listing 13.5 collection_create_list_delete.js: Creating, retrieving, and deleting collections on a MongoDB database
01 var MongoClient = require('mongodb').MongoClient;02 MongoClient.connect("mongodb://localhost/", function(err, db) {03 var newDB = db.db("newDB");04 newDB.collectionNames(function(err, collectionNames){05 console.log("Initial collections: ");06 console.log(collectionNames); ...
Read now
Unlock full access