Created
December 24, 2013 21:41
-
-
Save digilord/8118043 to your computer and use it in GitHub Desktop.
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
Meteor.startup () -> | |
# Countries collection initialization. | |
countries_csv = Assets.getText('country.csv') | |
csv = Meteor.require('csv') | |
countries_count = Countries.find().count() | |
if countries_count is 0 | |
Future = Npm.require('fibers/future') | |
future = new Future() | |
csv() | |
.from.string(countries_csv, {comment: '#'}) | |
.to.array (data) -> | |
return future.return(data) | |
results = future.wait() | |
for country in results | |
iso = country[0] | |
name = country[1] | |
selected = false | |
# Setup the default country. Do this so there is no | |
# flashing in the interface when the country list is | |
# populated then changed when there is no user selected | |
# country. | |
if name is 'United States' | |
selected = true | |
Countries.insert {iso: iso, name: name, selected: selected} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment