Pro MongoDB Development by Deepak Vohra

Pro MongoDB Development by Deepak Vohra

Author:Deepak Vohra [Vohra, Deepak]
Language: eng
Format: azw3
ISBN: 9781484215999
Publisher: Apress
Published: 2015-09-21T16:00:00+00:00


});

The findAllDocuments.js script is listed:

Server = require('mongodb').Server;

Db = require('mongodb').Db;

Collection = require('mongodb').Collection;

var db = new Db('local', new Server('localhost', 27017));

db.open(function(error, db) {

if (error)

console.log(error);

else{

db.createCollection('catalog', function(error, collection){

if (error)

console.log(error);

else{

doc1 = {"catalogId" : 'catalog1', "journal" : 'Oracle Magazine', "publisher" : 'Oracle Publishing', "edition" : 'November December

2013',"title" : 'Engineering as a Service',"author" : 'David A. Kelly'};

doc2 = {"catalogId" : 'catalog2', "journal" : 'Oracle Magazine', "publisher" : 'Oracle Publishing', "edition" : 'November December

2013',"title" : 'Quintessential and Collaborative',"author" : 'Tom Haunert'};

collection.insertMany([doc1,doc2], function(error, result){

if (error)

console.log(error);

else{

console.log("Documents added: "+result);

}

});

collection.find().toArray(function(error, result) {

if (error) console.warn(error.message);

else

console.log(result);

});

}

});

}});



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.