|
When calling WriteConcern with new, it works as expected:
> new WriteConcern({j: true})
|
WriteConcern({ "j" : true })
|
But without the new this fails:
> WriteConcern({j: true})
|
2016-04-06T15:43:44.271-0400 E QUERY [thread1] Error: If the first arg is an Object then no additional args are allowed! :
|
WriteConcern@src/mongo/shell/bulk_api.js:52:15
|
WriteConcern@src/mongo/shell/bulk_api.js:45:1
|
@(shell):1:1
|
I think this is because when this isn't called with new, it recurses, always passing 3 arguments:
if(!(this instanceof WriteConcern))
|
return new WriteConcern(wValue, wTimeout, jValue);
|
So we error here:
if (typeof wValue == 'object') {
|
if (arguments.length == 1)
|
opts = Object.merge(wValue);
|
else
|
throw Error("If the first arg is an Object then no additional args are allowed!")
|
}
|
|