javascript - Meteor - loop through Collection to delete the first x-many items -


i have fs collection in meteor called "myuploads". performing functionality on files uploaded collection, , additional files created , subsequently added within myuploads. have created event, in take place, called #parseuploads. within event, , prior addition of subsequent files added myuploads, have created variable:

var previouscount = filecount; 

which responsible storing original count of documents user had added collection. then, parsing function perform on each of these documents, , add newly parsed documents collection.

my question is: how loop through collection first document through previouscount's value document? in other words, if previouscount has value of 3 (meaning, user had uploaded 3 documents), after parsing functionality has been performed, there 3 subsequent documents added collection. know how can loop through collection , delete first 3 documents, while leaving 3 subsequent documents remaining in collection.

i recommend adding boolean field collection act flag denote parsed items. once item parsed, can update it.

then can remove items collection based on presence of flag.

mycollection.remove({stale: true}); 

hope helps,

elliott


Comments