Detect if Minimongo denied a collection write operation

47 Views Asked by At

How can the client code of a Meteor app detect that a write operation (insert, remove, update) against a collection was denied, so that it can display an appropriate error message?

Collection.remove(id)

The console will display:

remove failed: Access denied

1

There are 1 best solutions below

0
On

This is rather obvious, but Google didn't do a good job of surfacing the relevant documentation: you need to pass a callback parameter:

Collection.remove(id, function (error) {
  if (error)
    sAlert.error(error.toString());
});