Monday 15 February 2010

javascript - Can't delete items from Mongo Database in Meteorjs -



javascript - Can't delete items from Mongo Database in Meteorjs -

i have created object in meteorjs hold database info n numbers of dice rolls, , dice displayed using handlebars #each iterator. here of code:

the global mongo collection:

items = new meteor.collection('items');</code>

when roll dice, happens collection when button clicked:

//don't want bore code, here's of import parts... var randomnumber=math.floor(math.random() * numsides) +1); var numdice = 6;// it's variable passed in, here it's 6. (var = 0; < numdice; i++) { items.insert(item: randomnumber) };

and display info dice because displays numbers have css'd dice. i'm straying here... anyway, dice rolling awesome, want clear dice when roll again. right now, maintain adding up. , when seek utilize method delete mongo db items stuff, crashes app. since i'm not sure how debug yet in browser, need help, , i'mm going inquire here...

now, main problem is, when dice rolled again, want purge database , start again. new javascript , meteor, , come java && ruby land, suggestions appreciated.

i've tried

items.removeindexes(), items.purge(), items.remove({})

they freeze app, , numbers displayed in #each iterator still there. thought delete stuff, , force changes... no??? please help.

the code on github @ http://www.github.com/rabbitfighter81/dmware/

you should utilize remove method, if phone call client, can remove 1 document per call, , selector must refer documents _id field. so, here's illustration remove documents in collection client has:

class="lang-js prettyprint-override">thecollection.find().foreach(function(doc){ thecollection.remove(doc._id) })

javascript mongodb meteor handlebars.js meteorite

No comments:

Post a Comment