Created
April 25, 2013 01:45
-
-
Save anonymous/5456919 to your computer and use it in GitHub Desktop.
Simple method to remove all the documents from a collection. This adds a new truncate method to the Meteor.Collection prototype. The term "truncate" is taken from a similar TSQL operation "truncate". See http://dev.mysql.com/doc/refman/5.0/en/truncate-table.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Removes all documents from the collection | |
* @example testCollection = new Meteor.Collection('test') | |
* testCollection.truncate | |
*/ | |
Meteor.Collection.prototype.truncate = -> | |
@find().forEach (item) => | |
@remove item._id |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Converted to JS using http://js2coffee.org/ - hope you don't mind.