diff --git a/lib/Model.ts b/lib/Model.ts index 112ab9f..8ee3953 100644 --- a/lib/Model.ts +++ b/lib/Model.ts @@ -730,17 +730,16 @@ export class Model { return new Bluebird((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 = options; let out : {[op: string]: string} = {}; out[(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(); + }); }) } }