jamescarr/mongoosastic — pull request #37 by chapel (2012-08-27 19:54:07+00:00)
Title: Fix Bad Mapping in Serialize.js & Preserve Sort Order from ElasticSearch when Hydrating

The existing serialize function convertTypesAsNeeded was causing bad mapping due to closure leaking in the for loop. A simple fix was to grab the keys with Object.keys and wrap it in a forEach loop preserving closure.

The other issue was using sort in ElasticSearch would be clobbered due to MongoDB not returning results in the order given. It is a known issue, and the easy fix was to map the indexes of the original array so it could be reconstructed with the Mongoose documents, preserving the sort order from ElasticSearch