These are chat archives for Automattic/mongoose

8th
Dec 2015
Roger Serentill
@rserentill
Dec 08 2015 15:36
Hello guys, I don't know if this is the proper room, but I'll try. I have a simple question: if I'm using an array of strings in a model in mongoose, this array will keep the order, right? I mean, for example if I store [1, 2, 3, 4] it will always be [1, 2, 3, 4], not [2, 3, 1, 4]?
Valeri Karpov
@vkarpov15
Dec 08 2015 22:24
@daverich204 try running the same query in the mongodb shell and see if it works there. Might be an issue with how your data is stored in mongodb
@basiclaser mongodb is pretty smart about which index to use for which query, but you can try using hint: http://mongoosejs.com/docs/api.html#query_Query-hint, https://docs.mongodb.org/manual/reference/method/cursor.hint/#cursor.hint
@theosherry don't use require() in virtuals, and furthermore don't mock out require(), that's really questionable practice. Use a dependency injection framework instead
@rserentill correct. Arrays definitely maintain order and it's a major bug if they don't.