-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: 3.2.7
-
Component/s: Native
-
Environment:NodeJS v.8.11.4
discovered the issue on Windows, but Linux seems to be affected as well.
mongoose is affected too, but I've distilled the example to using pure mongodb module.
-
Empty show more show less
Trying to connect to database called "constructor" breaks something. The following code demonstrates the issue:
const mongo = require('mongodb').MongoClient; const goodUrl = 'mongodb://localhost:27017/constructor1'; const badUrl = 'mongodb://localhost:27017/constructor'; mongo.connect(goodUrl, {useNewUrlParser : true}) .then(client => { let db = client.db(); console.log('good:', typeof db); // 'good: object' }); mongo.connect(badUrl, {useNewUrlParser : true}) .then(client => { let db = client.db(); console.log('bad:', typeof db); // 'bad: function' });
Basically, any database name work fine, except "constructor"