MongoDB 3.0 and mongoDB 2.2
NickName:Aksenov Vladimir Ask DateTime:2018-01-26T23:34:18

MongoDB 3.0 and mongoDB 2.2

I create NodeJS V8 app and use mongoDB local server.

I had mongoDB version ^2.2.34 and connect to DB

    let mongodb = require('mongodb');
    let mongoClient = mongodb.MongoClient;

    let connection = mongoClient.connect('mongodb://localhost:27017/Test');

    let getCollection = function (c) {
        return connection.then(function (db) {
            return db.collection(c);
        });
    };

It worked. I update my mongoDB version to ^3.0.1 and have error

(node:16320) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: db.collection is not a function

Why in new version it isn't work and how I can change code?

Copyright Notice:Content Author:「Aksenov Vladimir」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/48464522/mongodb-3-0-and-mongodb-2-2

More about “MongoDB 3.0 and mongoDB 2.2” related questions

MongoDB 3.0 and mongoDB 2.2

I create NodeJS V8 app and use mongoDB local server. I had mongoDB version ^2.2.34 and connect to DB let mongodb = require('mongodb'); let mongoClient = mongodb.MongoClient; let

Show Detail

How to add user in mongodb 2.2?

Please I want to know how to add user in mongodb 2.2 I know createuser in mongodb 2.6 But can I add user in Mongodb 2.2?

Show Detail

Configuring mongodb 3.0 for memory limit

Does any one know how to limit memory in mongodb 3.0. I already know that it is not possible in mongodb 2.x version. But how to do that in 3.0 (WiredTiger). Mongodb is eating all the cache in my s...

Show Detail

Copy database using MongoDB 3.0 Java Driver

I'm trying to copy a database from a remote host running MongoDB v3.2 to a local one running MongoDB v3.0 using the MongoDB Java Driver 3.0. Using the shell, I'm easily achieving this by running: ...

Show Detail

Connecting to MongoDB 3.0 with Java Spring

I am having problems in using Spring to access MongoDB with credentials. While without credentials it works like a charme, using them just fails saying Failed to authenticate to database [

Show Detail

Connecting to MongoDB 3.0 with Java Spring

I am having problems in using Spring to access MongoDB with credentials. While without credentials it works like a charme, using them just fails saying Failed to authenticate to database [

Show Detail

mongodb3.0 can not run with my config file

this is my config file systemLog: destination: file path: "D:\\Program Files\\MongoDB\\Server\\3.0\data\\log\\mongodb.log" logAppend: true verbosity: 1 storage: engine: wiredTi...

Show Detail

MongoEngine version supporting mongoDB 3.0

Which version of mongoengine has started supporting MongoDB v3.0? MongoDB v3.0 compatibility is mentioned only in the documentation of latest version - v0.15.0. My current mongoengine version is ...

Show Detail

Uninstall mongoDB from ubuntu

I have installed MongoDB 3.0.1 following the commands in Install MongoDB Community Edition on Ubuntu on my ubuntu 14.04 64 bit system and I installed Robomongo interface to use that. When I try to

Show Detail

How to use $count aggregation operator(or workaround) in MongoDB 2.2?

I got 2 mongodb aggregation querys which worked fine until I needed to downgrade my mongodb version to 2.2 because it needs to run on a raspberry pi 4 (2.2 is the newest version working on a pi 4)....

Show Detail