-
Type:
Question
-
Resolution: Done
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
Environment:Windows 10, Core i5, 8 GB Ram
-
v3.4, v3.2
I am creating an sample library app in nodejs+express+mongodb. when I run the gulp serve command the server start perfectly. when I goto specific mongodb page then it giving error insertMany is not a function.
below is the page code:
var express = require('express');
var adminRouter = express.Router();
var mongodb = require('mongodb').MongoClient;
var books = [
,
{ title: 'Make of the world', genre: 'Digital India towards', author: 'Jumanji', read: false }];
var router = function (nav) {
adminRouter.route('/addBooks')
.get(function (req, res) {
var url = 'mongodb://127.0.0.1:27017/libraryAPP';
mongodb.connect(url, function (err, db) {
var collections = db.collections('books');
collections.insertMany(books,
function (err, results)
);
});
});
return adminRouter;
};
module.exports = router;