Coder Social home page Coder Social logo

Cant connect about mongodb-queue HOT 4 CLOSED

chilts avatar chilts commented on August 20, 2024
Cant connect

from mongodb-queue.

Comments (4)

mcnijman avatar mcnijman commented on August 20, 2024

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

from mongodb-queue.

coderofsalvation avatar coderofsalvation commented on August 20, 2024

versions should be fixed in #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.

from mongodb-queue.

mcnijman avatar mcnijman commented on August 20, 2024

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

from mongodb-queue.

chilts avatar chilts commented on August 20, 2024

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.

from mongodb-queue.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.