Mongojs a great mongoDB driver for nodeJS
Määntig,21 Dezämber, 2020

For my end of the year fun project I have spent some time testing the various mongodb drivers available for express.
Mongodb: the official driver is not as straightforward as it should
Mongose: I cannot understand why you would want to specify a model for a NOSQL database. It seems contra-intuitive and just wrong.

MongoJS has really the best API of all:

var mongojs = require('mongojs')
var db = mongojs('yourDBname', ['yourcollection'])

and you are connected to your local mongoDB.

db.posts.find(function (err, docs) {
  console.log(docs) // all your records
db.posts.insert({title: 'abcd', slug: 'cde'})   //  add one record
})

As simple as that. I like the fact that some developers spent the time to make such a cool and straightforward db connector. Of course it supports much more (even bulk inserts) so for more information see the mongojs readme.

Time to finish the full crud app with mongo as a backend! 🦜