guncebektas / meteor-friendly-slugs

Meteor package to generate URL friendly slugs from a field with auto-incrementation to ensure unique URLs.
65 stars 15 forks source link

Error: Not permitted. #27

Closed Tim-W closed 8 years ago

Tim-W commented 8 years ago

Topics.update( {slug: topicSlug}, { $addToSet: { posts: result } });

When I try to update a document using the slug attribute instead of _id, I get the following error: "Error: Not permitted. Untrusted code may only update documents by ID. [403]"

I understand why this error gets thrown, but what is the preferred workaround to update a single document selected by slug instead of _id?

todda00 commented 8 years ago

This is a restriction from Meteor, not this package. You can handle this one of two ways:

  1. Make sure the _id is available in whatever context you need to update the record and use that as the selector.
  2. Use a method to complete the update.