How to drop and create indexes in mongoose mongodb
<p>I have been trying to reset the unique key indexes while importing the data as shown below:</p>

<pre><code>const importData = function() {
   UserLocation.collection.dropAllIndexes((err) =&gt; {
    if (err) {
      console.trace(err);
      return;
    }
    UserLocation.collection.createIndex({
     Adfrom: 1,
     Adpto: 1
    }, {
     unique: true
    });

    fs.createReadStream(`${__dirname}/../data/import-data.csv`).pipe(parser);
   });
 };
</code></pre>

<p>Its working fine in my local environment but when i deploy this code iam getting mongodb connection error because of dropIndex.</p>

<pre><code>Error:
Mongoose default connection to mongodb://localhost:27017/userlocation disconnected
Mongoose default connection error: MongoError: connect ECONNREFUSED 127.0.0.1:27017
</code></pre>

<p>How to fix this issue.</p>

<p>Please help !</p>

<p>Thanks</p>