Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I remove an item from a lists collection in Meteor?

I'm following a book example about Meteor and I'm trying to remove an item, like this:

lists.remove({Category:"Fraggles"})

However, this doesn't work anymore in the last version of Meteor and I get the following console error: 403 reason: "Not permitted. Untrusted code may only remove documents by ID."

I found the id like this:

lists.findOne({Category:"Fraggles"})
Object {_id: "T88C6tx4G9YJpLzn5", Category: "Fraggles"}

But I do not know how to use the correct syntax to actually remove it. Any help would be appreciated.

Thank you!

like image 657
Valentin G. Avatar asked Apr 02 '13 11:04

Valentin G.


1 Answers

lists.remove('T88C6tx4G9YJpLzn5') will remove the document with the _id: T88C6tx4G9YJpLzn5.

http://docs.meteor.com/#remove

If you want to remove more than one document you can define a method which runs on the server and call from the client.

http://docs.meteor.com/#meteor_methods

like image 50
Kristoffer K Avatar answered Oct 24 '22 05:10

Kristoffer K