[SOLVED] Removing all documents from a collection


Hey guys,

I have an app that uploads a CSV file, and put them in a collection.
However, I want the database to be emptied whenever a new CSV file is uploaded after a click event.

I am trying to call MyCollection.remove({}); but it is not letting me, comes back with a “Denied” in the console.

After doing some research, for security reasons, it appears that I can’t delete everything, but rather one by one using ._id.

The suggestions online were all point towards Meteor.methods, but I am struggling with the syntax of it. Can you guys give me an example of how to do so? I’m merely a beginner and trying to learn. Thank you!


You can remove all the records on the Server side. Moreover, you may use rawCollection and drop it like a boss)

import {Meteor} from 'meteor/meteor';
import {Mongo} from 'meteor/mongo';

const Posts = new Mongo.Collection('posts');

  uploadCSVData(csvTextData) {
    check(csvTextData, String);
    // inserd new data next


the Posts.rawCollection().drop(); is exactly what I was looking for. You’re the boss here, my friend. Thank you so much.