title: Error while saving data in MongoDB atlas with mongoose
body: <p>I'm trying to save data in the MongoDB atlas with node.js and mongoose.</p>
  
  <p>Every time I use <code>MySchema.save()</code>, Data is inserting But I'm also getting the error:</p>
  
  <blockquote>
    <p><code>UnhandledPromiseRejectionWarning: MongoWriteConcernError: No write concern mode named 'majority;' found in replica set configuration</code></p>
  </blockquote>
  
  <p>Also, there is no duplicate entry, Data is also inserting But I'm also getting the error</p>
  
  <pre class="lang-js prettyprint-override"><code>let User = require('../models/users.models');
  
  const username = req.body.username;
  const newUser = new User({username});
  newUser.save()
  .then(() =&gt; res.json('user added!'))
  .catch(err =&gt; res.status(400).json('Error: ' + err));
  </code></pre>
  
  <p><strong>User model</strong></p>
  
  <pre class="lang-js prettyprint-override"><code>const mongoose = require('mongoose');
  const Schema = mongoose.Schema;
  
  var userSchema = new Schema({
      username:  {
          type: String,
          required: true,
          unique: true,
          trim: true,
          minlength: 3
      },
    },
    {
      timestamps: true
    });
  
  const User = mongoose.model('User', userSchema);
  
  module.exports = User;
  </code></pre>