Custom Database (MongoDB Altas) script template In signup user doesn't get created get an error

I also receive this error using the default create mongodb template.

I modified it accordingly to be able to use atlas…

function create(user, callback) {
  const {MongoClient} = require("mongodb@3.1.4");
  const bcrypt = require('bcrypt');

	const uri = `mongodb+srv://${configuration.DB_USER}:${configuration.DB_PASSWORD}@${configuration.DB_HOST}/test?retryWrites=true`;
  const client = new MongoClient(uri, { useNewUrlParser: true });

  client.connect(err => {
    if (err) return callback(err);

    const users = client.db(configuration.DB_NAME).collection(configuration.USERS_COLLECTION);

    users.findOne({ email: user.email }, function (err, withSameMail) {
      if (err) return callback(err);
      if (withSameMail) return callback(new Error('the user already exists'));

      console.log('hashing');
      bcrypt.hash(user.password, 10, function (err, hash) {
        if (err) return callback(err);
        user.password = hash;
        users.insert(user, function (err, inserted) {
          if (err) return callback(err);
          callback(null);
        });
      });
    });
  });
}