How to store data for countries?

I need to store a couple variables for every country in the world in a collection that will be displayed in a table (The variables are dynamic). The problem is, when I deploy a site the database is reset. What is the best approach to adding in the countries? Also, as an update for anyone who saw my question last night; it is going really well in regards to how to use templates and what not :smiley:

Currently my idea is to have it check if a country exists in the countries collection on startup, if not it will add all them in via hardcode. Not sure if this is the best way to go about it but I think it will work. (if anyone has a better way feel free to tell me still!)

Well, you could add Seed data to your project. So in general, add a countries.json file some where in a folder like /private/imports.
Then in you server/startup folder add a file like ‘importCountries.coffee’

Meteor.startup ->
    if countries.find().count() is 0
        Meteor.call( 'doCountriesImport') 

The function doCountriesImport would be a function on the server that read the seed file.
You can read files by using Assets, check the first answer on this link:

Then when you have read the file, iterate it and add your records to your Collection.

Would this help?

1 Like

That sounds like a way better idea than mine! Will implement it later however, got exams tomorrow X_X Thanks for the help man!