Meteor Upsert zulassen?
Diesen Fehler in der Konsole erhalten, wenn ich versuche, ein Upgrade auf eine Sammlung durchzuführen:
"Aktualisierung fehlgeschlagen: Zugriff verweigert. Upserts in einer eingeschränkten Sammlung nicht zulässig."
Hier sind die Zulassungsregeln, die ich angegeben habe:
if (Meteor.isClient) {
Meteor.subscribe('customers');
}
customers = Customers
if (Meteor.isServer) {
Meteor.publish('customers', function() {
return customers.find();
});
customers.allow({
insert: function (document) {
return true;
},
update: function () {
return true;
},
remove: function () {
return true;
}
});
}
Hier ist der Umkehrteil:
Customer.prototype.create = function ( name, address, phone, cell, email, website, contact, shipping ) {
var attr = {
name : name,
address : address,
phone : phone,
cell : cell,
email : email,
website : website,
contact : contact,
shipping : shipping
};
Customers.upsert( Customers.maybeFindOne( attr )._id, attr );
return new Customer( attr );
};