I'm trying to connecto to a mongoDB and count for all documents of an article:
var MongoClient = require('mongodb').MongoClient
var mongoUrl = 'mongodb://localhost:27017/test'
MongoClient.connect(mongoUrl, function (err, db) {
if (!err) console.log('Connected successfully to server: ' + mongoUrl)
var articles = db.collection('articles')
console.log(articles.count())
db.close()
})
But I do get the output Promise { <pending> }
instead of a number.