Ad

Exception In Mongo Write When Removing Multiple Documents

- 1 answer

I need to remove documents which meet certain criteria...

server/methods.js

Meteor.methods({
  rA: function (a) {
        As.remove({aId:a}, {multi:true});
    }
});

As collection has documents with the same aId, it is a

client/js

var a = this.aId;
Meteor.call('rA', a);

I got following error on my terminal:

I20151231-06:39:24.849(7)? Exception in Mongo write: TypeError: object is not a function
I20151231-06:39:24.850(7)?     at packages/mongo/mongo_driver.js:322:1
I20151231-06:39:24.851(7)?     at runWithEnvironment (packages/meteor/dynamics_nodejs.js:110:1)

How do I remove multiple documents?

Thank you and happy new year... ^_^

Ad

Answer

There is no {multi:true} for the removing method. It should be

As.remove({aId:a});

multi is only for update. Check out the documentation in here

Ad
source: stackoverflow.com
Ad