elliotf / mocha-mongoose

test helpers for using mongodb with mocha
MIT License
107 stars 21 forks source link

How about handle collection index #5

Closed xiaods closed 11 years ago

xiaods commented 11 years ago

I found collection.remove don't remove relative index, how to handle it?

elliotf commented 11 years ago

Are you referring to indexes (schema) that get auto-created by mongoose? If so, I had a similar problem, but I'm not sure that removing indexes is the job of mocha-mongoose. That seems more like a migration problem. I agree that it's a problem due to mongoose (potentially) auto-creating indexes.

I would welcome a pull request for this feature. The test would likely create a unique index, clear the database, then try to create two documents that would have conflicted if the unique index were still there.

elliotf commented 11 years ago

No response from issue opener, but I'm assuming this is similar to #6.

elliotf commented 11 years ago

To give a constructive answer of how to drop indexes, I suggest you look at the stack overflow post: http://stackoverflow.com/questions/13014548/what-is-the-recommended-way-to-drop-indexes-using-mongoose

xiaods commented 11 years ago

@elliotf thanks, it's works for the stackoverflow

elliotf commented 11 years ago

I'm glad it works for you, @xiaods !