'process.nextTick(function() { throw err; })' - Undefined is not a function (mongodb/mongoose)

后端 未结 3 550
有刺的猬
有刺的猬 2020-12-16 15:50

I\'m trying to connect to my mongodb using nodejs and socket.io. I am able to connect to the database because I get \'connection accepted\' in my console bu

3条回答
  •  隐瞒了意图╮
    2020-12-16 16:23

    Shouldn't you specify the full path and have an export module?
    ...something like:

    mongoose.connection.db.collectionNames(function (err, names)
    {
            console.log(names); // [{ name: 'dbname.myCollection' }]
            module.exports.Collection = names;
    }
    

    If I'm wrong it's because I don't fancy moongodb :)

提交回复
热议问题