Move more mongo specific stuff into mongo adapter

This commit is contained in:
Drew Gross
2016-05-23 21:16:03 -07:00
parent 05ae010b91
commit 3ed3c7b62f
2 changed files with 22 additions and 25 deletions

View File

@@ -200,8 +200,9 @@ export class MongoStorageAdapter {
// Executes a find. Accepts: className, query in Parse format, and { skip, limit, sort }.
find(className, query, schema, { skip, limit, sort }) {
let mongoWhere = this.transform.transformWhere(className, query, schema);
let mongoSort = _.mapKeys(sort, (value, fieldName) => transform.transformKey(className, fieldName, schema));
return this.adaptiveCollection(className)
.then(collection => collection.find(mongoWhere, { skip, limit, sort }))
.then(collection => collection.find(mongoWhere, { skip, limit, sort: mongoSort }))
.then(objects => objects.map(object => transform.mongoObjectToParseObject(className, object, schema)));
}