Where should I create a user-populated array for a Mongo selector?

This is related to a previous post that I ended up resolving, regarding pushing values to an array. Turned out that was just a javascript question but I think this is more Meteor-related.

I have the code below for adding a value to an array on button click. The array is then used as part of a Mongo selector to populate a datatable using the aldeed:tabular package. My issue is related to where I should create the compset array. This code is in the client folder, so while the array populates properly, the data clears with just a browser refresh.

Where should this be defined? I’ve been researching this but I only find documentation on 1) how to insert to or modify a collection, which I am not trying to do or 2) how to use an array where the values are in the code, which doesn’t help at all. I can’t figure out how to create an array that lives on. Is this related to local collections? That still doesn’t feel like it would make sense, since it would be created in the browser.

Thanks very much!


//Define array "compset"
compset = ["Example"];

Template.CompanyComps.events ({
    //Click button with class "addComp"
    'click .addComp': function (event) {
        //Prevent default
        //Push value of input with name "comp" to array "compset"
        return compset;

    comps: function () {
        //Define selector for datatable - select documents whose "name" is in "compset" array
        return {name: {$in: compset}};