Skip to content

Commit

Permalink
Fix code quality with mapReduce
Browse files Browse the repository at this point in the history
  • Loading branch information
RagibHasin committed May 29, 2017
1 parent c79b2a4 commit 5eb054f
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions lib/Model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -730,17 +730,16 @@ export class Model<TDocument extends { _id?: any }, TInstance> {
return new Bluebird<void>((resolve, reject) => {
if (options.out && options.out == "inline")
return reject(new Error("Expected a non-inline mapReduce output mode for this method signature"));
if (!instanceType.mapReduceOptions)
return reject(new Error("mapReduceOptions not provided"));
let opts = <MongoDB.MapReduceOptions>options;
let out : {[op: string]: string} = {};
out[(<string>options.out)] = instanceType.collection;
opts.out = out;
if (instanceType.mapReduceOptions) {
this.collection.mapReduce(instanceType.mapReduceOptions.map, instanceType.mapReduceOptions.reduce, opts, (err, data) => {
if (err) return reject(err);
return resolve();
});
}
else return reject("mapReduceOptions not provided");
this.collection.mapReduce(instanceType.mapReduceOptions.map, instanceType.mapReduceOptions.reduce, opts, (err, data) => {
if (err) return reject(err);
return resolve();
});
})
}
}
Expand Down

0 comments on commit 5eb054f

Please sign in to comment.