I tried using remove() for each collection item in a for loop, and that appeared to be successful. However, the items are still in the collection. I will be happy to just remove the collection entirely if there is a way to do it via JavaScript.
Here is the returned object after each remove() - in console.log:
deleted ID1[object Object]
dbsetup.js:304 1 - deleted ID2[object Object]
dbsetup.js:304 2 - deleted ID1ee7978aa5ddc20[object Object]
dbsetup.js:304 3 - deleted ID2899af1e797ff00[object Object]
dbsetup.js:304 4 - deleted ID2234cd96dac8380[object Object]
dbsetup.js:304 5 - deleted ID348a5bcd5f0f600[object Object]
dbsetup.js:304 6 - deleted ID490930bb2589c80[object Object]
And here is my function that uses forerunner's remove():
function removeAllGames() {
var gameArray = games.find();
var gameID;
var deletedObject;
var len = gameArray.length;
for (var i=0;i<len;i++) {
gameID = gameArray[i]._id;
deletedObject = games.remove({
_id: gameID
});
console.log(i + " - " + "deleted ID" + gameID + deletedObject);
}
}
I'll report my progress - thanks for your help!
I figured it out! I need to use the save() function after the remove() function. After doing this, the items where permanently gone from the collection. I still need to figure out how to delete the collection itself, but for now this is enough to get the job done.
I recommend looking at the forerunnerdb tutorials, and not just relying on the documentation on github (like I did). The tutorials give working examples on how to save properly.