A
A
Alexey Yakovlev2020-02-27 14:05:10
MongoDB
Alexey Yakovlev, 2020-02-27 14:05:10

Error when turning on the server on mongodb what to do?

Wrote:

MongoClient.connect('mongodb://localhost:27017/alldatabase', function(err, database) {
    useUnifiedTopology: true;
    useNewUrlParser: true;

    if (err) {
        return console.log(err);
    }
    // Ссылка на бд
    db = database;
    app.listen(3000, function() {
        console.log('Подключение');
    });
});


Error:
DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Cheremkhin, 2020-02-27
@aleshaykovlev

Apparently a bug in MongoClient.connect

// Запуск сервера
MongoClient.connect('mongodb://localhost:27017/alldatabase', function(err, database) {
    useUnifiedTopology: true;  //  <---????
    useNewUrlParser: true;  //  <---???? неправильно опции установлены

   ...

Right below
// Запуск сервера
MongoClient.connect(
  'mongodb://localhost:27017/alldatabase',  // строка подключения
  {
     useUnifiedTopology: true,  // установка опций
     useNewUrlParser: true
  },
  function(err, database) {  // callback
    if (err) {
        return console.log(err);
    }
    // Ссылка на бд
    db = database;
    app.listen(3000, function() {
        console.log('Подключение');
    });
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question