82

Is there a simple way to reset the data from a meteor deployed app?

So, for example, if I had deployed an app named test.meteor.com — how could I easily reset the data that has been collected by that app?

Locally I run meteor reset, but I am unsure of what to do in production.

4 Answers 4

108

If you have your app with you you could do this in your project directory

meteor deploy test.meteor.com --delete
meteor deploy test.meteor.com 

The first deletes the app so its all blank. The second deploys a fresh instance of it back.

4
  • Hey @akshat, do you think stackoverflow.com/questions/10214385/how-does-meteor-work should be reopened? Commented Mar 13, 2014 at 19:41
  • this seems like a bit of a hack. is there no cleaner way?
    – dcsan
    Commented Oct 29, 2014 at 0:20
  • Will this code cause the URL to be up for grabs temporarily? Commented Nov 6, 2015 at 16:06
  • this has nothing to do with resetting an app data in production, and I don't understand why this answer got so many upvote
    – MickaelFM
    Commented Apr 20, 2017 at 5:24
43

one way is to login to the mongo instance yourself and delete the relevant data so something like per collection:

$ meteor mongo APP.meteor.com
> db.users.drop()
> db.xxx.drop()

you could just drop the whole DB, but that would confuse their env and you have to --delete the app and re-deploy anyway.

> db.dropDatabase()
4
  • 2
    This should be the accepted answer, you spared me a rebuild + reupload, thanks !
    – saimeunt
    Commented Nov 3, 2014 at 4:34
  • doing this in production with logged users is a bad thing!
    – DATEx2
    Commented Nov 16, 2014 at 13:19
  • 2
    @DotNetWise: You're not supposed to have a production APP.meteor.com. At best you have a beta there, and with it being a beta, people know to expect hiccups like this (if their entire account and everything they ever did being deleted counts as a hiccup. Imagine if Facebook did that - I wonder how many people would bother staying and recreating everything.) Commented Mar 28, 2015 at 2:39
  • Great suggestion - simply dropping a few databases was all I really needed to do. Commented Mar 28, 2015 at 2:42
3

I know this is a bit old, but I just changed my collection name. so in your /lib/collections.js file,

someCollection = new Mongo.Collection("originalcollection");

becomes

someCollection = new Mongo.Collection("newcollectionname");

this is assuming of course that your app generates the data for the database.

3
  • 1
    You haven't removed the old collection here, you just created a new empty one. If you did this in an app running on a server (instead of just locally), you will still have data persisting on your server inside a collection named originalcollection.
    – kahmali
    Commented Apr 18, 2015 at 20:36
  • 1
    Yeah @krose, I recognize that, but the point is that it's easy and fast if you need to test something. As others pointed out, you don't use myapp.meteor.com for production. And if you did, you DEFINITELY wouldn't want to just drop a production database. I do this strategy to safely try new things with my model without compromising data. IMHO this response wasn't so bad that it deserved a down vote, as it's a much safer way to deal with production data. you can then always drop the specific collection, as @dcsan's comment explains
    – Dave
    Commented Apr 20, 2015 at 4:39
  • 1
    seems like a quick hack you can use if you know what you're doing :) upvoted to balance the downvote :)
    – dcsan
    Commented Apr 27, 2015 at 20:44
1

Simply you can access your meteor DB as

production-db-d2.meteor.io:27017/XYZ_meteor_com

where XYZ = your subdomain

for authentication use meteor auth (username & password)

You can access it from rockmongo, robomogo, mongoui, etc tools.

To access from command line

First authenticate by typing username, password of meteor

$ meteor login

Then

$ meteor mongo XYZ.meteor.com

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.