javascript - Can't delete items from Mongo Database in Meteorjs -
I created an object in Metsz so that the database number is for n parse roll, and then the dice is displayed using the dice Handler # icterator Here are some of my codes:
Global Mongo archive:
items = new meteor. Compilation ('item'); & Lt; / Code & gt; When I roll the dice, this is when a button is clicked:
// You do not want to bore all Code, so here are just the important parts ... var randomNumber = Math.floor (Math.random () * numSides) +1); Var numDice = 6; // This is really a variable passed, but here it is 6. (Var i = 0; i & lt; numDice; i ++) {items.insert (item: randomNumber)}; And then they display the information as dice because this number shows that I have CSS to look like a dice but I'm wandering here ... However, Dice rolling is great, but when I roll again, I want to clean the dice. Now, they just keep adding and when I try to use any way to remove the Mongo DB item, it crashes my app because I'm not sure that in a browser very well yet How to debug, I need some help, and I'mm going to ask it here ...
Now, my main problem is that when the dice is rolling again, Cleanse and again Uru want to. I'm new to Javascript and Meteor, and Java & amp; Amp; Ruby land, therefore any suggestions are greatly appreciated.
I've tried
items .removeIndexes (), items.purge (), Items.remove ({}) They all just freeze my app, and the numbers shown in the # indicator are still present. I thought it would remove the stuff, and push the changes ... no ... Please help.
The code is on GitHub @
You should use the method, but if You tell it to the client, you can only remove a document per call, and the selector should refer to the document _id field. Therefore, here is an example to remove all the documents present in the client:
TheCollection.find (). ForEach (function (doc) {TheCollection.remove (doc._id)})
Comments
Post a Comment