Meteor.startup works only with meteor reset

Hello,
I have some data at server folder with Meteor.startup() which appears at page startup.If I make a change there nothing happens and it works only if I meteor reset.I don’t want this to happen since I lose everything else created in the database.Even if I restart meteor the changes still don’t occur .I probably don’t understand something and how reactive works.

Do you happen to have a sanity check before you insert any “initial” data in that Meteor.startup()?

Going by what you describe, since meteor reset cleans DB aswell, the data isn’t inserted because it already exists

I m using Meteor.startup because I want something to appear at first page .I m saying that whatever change I made doesn’t make any difference unless I have made meteor reset which loses everything else inserted.

Can you post the code/part of it from your Meteor.startup()?

` Meteor.startup(function () {
        // code to run on server at startup
        if (!Websites.findOne()){
            console.log("No websites yet. Creating starter data.");
            Websites.insert({
                title:"Goldsmiths Computing Department",
                url:"http://www.gold.ac.uk/computing/",
                upVotes:0,
                downVotes:0,
                description:"This is where this course was developed.",
                createdOn:new Date()
            });
            Websites.insert({
                title:"University of London",
                url:"http://www.londoninternational.ac.uk/courses/undergraduate/goldsmiths/bsc-creative-computing-bsc-diploma-work-entry-route",
                upVotes:0,
                downVotes:0,
                description:"Univery of London International Programme.",
                createdOn:new Date()
            });

        }

    });`indent preformatted text by 4 spaces``

If I make a change there or add something no changes occur unless meteor reset .

That is the reason right there, as I mentioned in the first reply, since it’s a “sanity check”, no part of the code past that if (!Websites.findOne()){} gets executed once it has done it the first time - it inserts the initial university - so the next time Meteor.startup() is run, the if does not evaluate to true.

One thing you can do, if you really want, is to add a Websites.remove({}); right before the sanity check, that way only the Websites collection would be cleared on each Meteor.startup() and not ALL of the other data(what meteor reset does).

Hopefully that helps you

1 Like

And I thought you were talking about my sanity since I burned some cells so many continuous hours coding(lol just kidding).Thank you it worked!