Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@bangbang93
Last active April 3, 2019 07:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bangbang93/925fad7317c7f09ea4edae57da2d3a3e to your computer and use it in GitHub Desktop.
Save bangbang93/925fad7317c7f09ea4edae57da2d3a3e to your computer and use it in GitHub Desktop.
mongoose-issue
const mongoose = require('mongoose')
mongoose.connect('mongodb://localhost/test')
const schema = new mongoose.Schema({}, {strict: false})
const model = mongoose.model('test', schema)
model.collection.indexExists('users.user_1', (err, res) => {
console.log(err, res)
if (res) return model.collection.dropIndex('users.user_1')
})
const mongoose = require('mongoose')
mongoose.connect('mongodb://localhost/test')
const schema = new mongoose.Schema({}, {strict: false})
const model = mongoose.model('test', schema)
model.collection.indexExists('users.user_1')
.then(async (res) => {
if (res) return model.collection.dropIndex('users.user_1')
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment