Closed rncortes1990 closed 5 years ago
It's probably because you are passing a MongoClient instance to mongodb-queue that is a newer version than the outdated one used by this module. The new versions do not automatically create a Db instance, so you should use client.db('name'), but also the method Db.collection without a callback used here in strict mode is deprecated in current versions: http://mongodb.github.io/node-mongodb-native/2.2/api/Db.html#collection http://mongodb.github.io/node-mongodb-native/3.0/api/Db.html#collection
versions should be fixed in https://github.com/chilts/mongodb-queue/pull/28
otherwise it's totally up to NPM to always install the latest mongodb package, which will prevent people from running this nice queue.
NOTE: this only works standalone. Chances are that you're already running some kind of mongodb version.
MongoDB 3.x introduced a breaking change: mongodb.MongoClient.connect
doesn't return a mongodb.Db
instance but a mongodb.MongoClient
instead, so @rncortes1990 example should be changed into:
var mongodb = require('mongodb')
var mongoDbQueue = require('mongodb-queue')
var con = 'mongodb://localhost:27017/test'
mongodb.MongoClient.connect(con, function(err, client) {
var db = client.db('test') // notice this
var queue = mongoDbQueue(db, 'my-queue')
})
And it should work as expected. See for more: https://github.com/mongodb/node-mongodb-native/blob/master/CHANGES_3.0.0.md
v4.0.0 was released around 7 months ago and I think it should fix your problem. Please re-open if this isn't the case. Many thanks.
Hi, Im trying to use this package on my mongodb database but the mongoqueue is not working, I checked database URI and its okay.
This is the code and the error
thanks for your time.