Best practices to make one time mongodb calls before startup of meteor server


Greetings fellow meteorites!
I need to make some one time mongoDb calls (for the purpose of inserting static data). Ideally the best time would be before startup of server, before logic tries to access data that is not there. What is best practice to include a startup file that makes data calls - in this case - inserts data ?

Thank you so much for you help.
Any input is appreciated!


You are doing it wrong :wink:
Meteor is reactive, which means that if logic can’t access your data, that’s not a problem since when your data is later available, logic will rerun and access it.
So your one time insert can be done when you want, usually in a callback passed to Meteor.startup()


Guys this was a silly question. After reading over the documentation, it appears the best way to do this would be by making use of “Meteor.startup”.
Taken straight from the documentation:

 (Meteor.isServer) {
  Meteor.startup(function () {
    if (Rooms.find().count() === 0) {
      Rooms.insert({name: "Initial room"});


Thank you mate. Beat me to it! Was a matter of reading over the docs!