You seem to have your functions mixed around even though I clearly see what you are trying to do.
Your batch
you are passing in contains an array of documents that you want to insert/update. The problem is that this functionality is only available to the insert method.
Since you are using the update method, the option to pass in an array of documents for batch processing is not available. Updates with upsert set as you have done are intended to be issued with the primary arguments of a selector
and a single 'document'. The idea being that where the selector
matches an existing document, that document is updated with the details in document
. In the event the match is not found, then a new document is then inserted.
Additionally as you have not used, there is the multi option that can be applied. It's purpose is that when the selector
matches more than one document, then the changes are applied to all of the matching documents. Unspecified the behavior is considered to be false and only the first matching document found will be updated.
It would seem that though you wish to have this accompanied by a batch processing functionality, it does not presently exist. There is a JIRA you can follow / support for this.
https://jira.mongodb.org/browse/SERVER-2172
Refer to the links for the functions in the documentation, which explains all the available arguments and options. Also see the shell documentation for a detailed explaination of the options:
http://docs.mongodb.org/manual/reference/method/db.collection.update/