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.

blong
  • 2,815
  • 8
  • 44
  • 110
CaptConrado
  • 1,043
  • 1
  • 8
  • 9

4 Answers4

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.

Tarang
  • 75,157
  • 39
  • 215
  • 276
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()
dcsan
  • 11,333
  • 15
  • 77
  • 118
  • 2
    This should be the accepted answer, you spared me a rebuild + reupload, thanks ! – saimeunt Nov 03 '14 at 04:34
  • doing this in production with logged users is a bad thing! – DATEx2 Nov 16 '14 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.) – ArtOfWarfare Mar 28 '15 at 02:39
  • Great suggestion - simply dropping a few databases was all I really needed to do. – ArtOfWarfare Mar 28 '15 at 02: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.

Dave
  • 433
  • 3
  • 9
  • 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 Apr 18 '15 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 Apr 20 '15 at 04:39
  • 1
    seems like a quick hack you can use if you know what you're doing :) upvoted to balance the downvote :) – dcsan Apr 27 '15 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

Nishchit
  • 18,284
  • 12
  • 54
  • 81