I'm doing activity to learn about NodeJS and MongoDB, and during the project, I have the error below:
TypeError: this._connection.open is not a function
As I am still in the learning phase, I could not understand it well, but it seems to me that the problem is with the "open".
The UsersDAO file has the following code:
function UsuariosDAO(connection){
this._connection = connection();
}
UsuariosDAO.prototype.inserirUsuario = function(usuario){
this._connection.open( function(err, mongoclient){
mongoclient.collection("usuarios", function(err, collection){
collection.insert(usuario);
mongoclient.close();
});
});
}
module.exports = function(){
return UsuariosDAO;
}
And part of the cadastro.js file that appears listed in the error:
var connection = application.config.dbConnection;
var UsuariosDAO = new application.app.models.UsuariosDAO(connection);
UsuariosDAO.inserirUsuario(dadosForm);
Anyway, what would be the best solution to this problem?