Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Meteor: Can't replace document in restricted collection

Tags:

meteor

I am using Meteor 4.2 (Windows) and I am always getting the "update failed: 403 -- Access denied. Can't replace document in restricted collection" when I am trying to update an object in my collection. Strangely I had no problem inserting new ones, only updates are failing.

I tried to "allow" everything on my collection:

Maps.allow({
    insert: function () { return true; },
    update: function () { return true; },
    remove: function () { return true; },
    fetch: function () { return true; }
});

But still, this update fails:

Maps.update({ 
    _id: Session.get('current_map') 
}, {
    name: $('#newMapName').val()
});

Is there something else I can check? Or maybe my code is wrong? Last time I played with my project was with a previous version of Meteor (< 4.0).

Thanks for your help.

PS: Just for information, when I do this update, the local collection is updated, I can see the changes in the UI. Then very quickly it is reverted along with the error message, as the changes has been rejected by the server-side.

like image 617
TigrouMeow Avatar asked Oct 12 '12 09:10

TigrouMeow


1 Answers

Alright, the syntax was actually incorrect. I don't understand really why as it was working well before, but anyway, here is the code that works fine:

Maps.update({ 
    Session.get('current_map') 
}, {
    $set: { 
        name: $('#newMapName').val()
    }
});
like image 194
TigrouMeow Avatar answered Nov 15 '22 11:11

TigrouMeow