thisissami
thisissami

Reputation: 16373

node-mongodb-native example code vs docs code? which to use?

I just wrote my first nodejs program using the node-mongodb-native driver. I used the documentation code from the github page, i.e.:

var mongodb = require("mongodb"),
  mongoserver = new mongodb.Server('localhost', 6574),
  dbConnector = new mongodb.Db('test', mongoserver);

dbConnector.open(function(err, db){
  if(err)
    console.log('oh shit! connector.open error!');
      else{  
        ...

However, upon looking at some example code on the github page, I discovered that the set up code looks very different from what I used. Does anybody know if there's any real difference between the different methods? I'm completely new to all this stuff and can't really tell if there's any reason to use one over the other. The code I wrote seems to run fine, but if the creator of the driver is using different code, I figured it would be worth checking if there are any reasons for that.

Thanks in advance for any replies!

Sami

Upvotes: 0

Views: 633

Answers (1)

christkv
christkv

Reputation: 4440

Hi I'm the creator and no there is no particular reason you can't use your style. As when it comes to docs I usually tell people to start with the integration tests as there are many examples on how to do stuff. Unfortunately due to having a fulltime job the docs are not kept up to date at the pace I would like to.

I'm hoping to do something with that come late september but right now I'm trying to just get the driver up to the expected features of mongodb including making it work with 1.9.X and higher.

I'll accept any docs pull requests happily as the more the community help me the more it helps itself :)

Upvotes: 1

Related Questions