i'm trying to create a node which uses the mongodb api to connect to a mongodb database.
I inserted mongodb:require('mongodb') in the setting.js and additional "mongodb": "*" in the package.json, don't know if this is required.
I allways get the modules over the global context like var MongoClient = global.get('mongodb').MongoClient.
MongoClient.connect(...) works well i get a database connection and can make operations, but when i try to use a MongoClient object there occures the following error when i call the open function: TypeError: mongodb.open is not a function.
var MongoClient = global.get('mongodb').MongoClient;
var Server = global.get('mongodb').Server;
var mongodb = new MongoClient(new Server("localhost", 27017));
mongodb.open(function(err, mongodb) {
});
Thank you for your answer, i want to make it with a function node.
The code i showed you is only for the first test....firstly i want to make it run.
MongoDb is installed in ~/.node-red/ and yes my settings.js look like this.
When you say API you mean you’re looking for a reference of defined functions/properties available? Check the docs on the mongo site, for their JavaScript bindings.
Thanks, but based on what has been discussed here, not everything in the mongo docs/ api isn't obviously correct/ actual. kuema posted a link to the change log on github but i cann't find these changes in the current api.