Skip to content

Commit

Permalink
tweak: Make mapReduce output errors a bit easier to understand
Browse files Browse the repository at this point in the history
  • Loading branch information
notheotherben committed May 18, 2017
1 parent 5a7b63d commit a02dc9a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/Model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ export class Model<TDocument extends { _id?: any }, TInstance> {
if ((<fn>functions).map) {
return new Bluebird<MapReducedDocument<Key, Value>[]>((resolve, reject) => {
if (options.out && options.out != "inline")
return reject(new Error("Use inline output option"));
return reject(new Error("Expected inline mapReduce output mode for this method signature"));
let opts = <MongoDB.MapReduceOptions>options
opts.out = { inline: 1 }
this.collection.mapReduce((<fn>functions).map, (<fn>functions).reduce, opts, function (err, data) {
Expand All @@ -728,7 +728,7 @@ export class Model<TDocument extends { _id?: any }, TInstance> {
let instanceType = <InstanceImplementation<MapReducedDocument<Key, Value>, any> & { mapReduceOptions: MapReduceFunctions<TDocument, Key, Value> }>functions
return new Bluebird<void>((resolve, reject) => {
if (options.out && options.out == "inline")
return reject(new Error("Output cannot be inline"));
return reject(new Error("Expected a non-inline mapReduce output mode for this method signature"));
let opts = <MongoDB.MapReduceOptions>options
let out : {[op: string]: string} = {}
out[(<string>options.out)] = instanceType.collection
Expand Down

0 comments on commit a02dc9a

Please sign in to comment.