Created
November 20, 2014 13:49
-
-
Save gistfrojd/193e640b0bf74db5020f to your computer and use it in GitHub Desktop.
mongoose mocha ensureIndex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Mongoose.js and mocha/should testing with unique index constraints | |
// Use this snippet in your test, change the values to match your indexes | |
beforeEach(function(done) { | |
mongoose.connection.models.YourModelNameHere.collection.ensureIndex( | |
{ | |
fieldWithConstraint: 1, | |
anotherFieldWithConstraint: 1 | |
}, | |
{ | |
unique: true | |
}, function(err, data) { | |
done(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment