Error: Mongo selector can't be an array

I am trying to write a Meteor front end to an AWS service. All goes well until I try to insert or update the collection with json data received from an AWS api call. The data I’m interested in exists in an array in the json returned returned by the API call. To insert/update the collection I have to loop through the array to get to the element, so it looks something like this:

for (var i=0, len=data.Reservations.length; i<len; i++) {

which yields the following error: Error: Mongo selector can’t be an array.

I’ve tried various different approaches without any success. Any help would be greatly appreciated.


Are you sure that Instances is an object? Only objects are valid Mongo documents. If Instances is an array, you would have to wrap it with an object. Insert expects complete documents. If you want to just add values to a key inside an existing document, you would have to use update.