Advice needed with Simple Schema + Publish Subscribe


#1

I have implemented some basic schemas associated with collections. The schemas are located under /project/both/collections

Each schema has it’s own reference to the mongo collection.
I’ve followed SimpleSchema documentation as provided by aldeed.

For simplicity’s sake, let’s assume the below is my schema.

EG.,

import { Mongo} from 'meteor/mongo';

basicColleciton = new Mongo.Collection('BasicCollection');

basic_schema = new SimpleSchema ({
    "name":{
        type: String,
        regEx: /^[a-zA-Z0-9][\w@.-]{0,30}$/,
        autoform:{
            placeholder: "Alphanumeric, Inclusive of '_' '-' '@' '.'"
        }
    },
    "mode": {
        type: String,
            defaultValue: 'active',
            autoform:{
                type: "select-radio-inline",
                options: function(){
                    return [
                        {label:"Active", value:"active"},
                        {label:"Passive", value:"passive"}
                    ];
                }
            }
        }
});

basicColleciton.attachSchema(basic_schema);

What I want to do right now is separate out the the drop down / radio options from the schema and have it defined in a separate collection so that I may reuse the same in other schemas. How exactly do I do that?

I right now have a new collection in the mongo back-end:

meteor:PRIMARY> db.EnableOptions.find({});
{ "_id" : ObjectId("5763b98a4448ea0b948a6857"), "label" : "Active", "value" : "active" }
{ "_id" : ObjectId("5763b9ca4448ea0b948a6858"), "label" : "Passive", "value" : "passive" }

The second advice I seek is, how do I make use of publish / subscribe here? Both at the EnableOptions level as well as the global schema level.

I went through meteropedia’s method of publish subscribe. However, it requires me to define mongoCollection reference again at server.js. When I try to do that I it gets errored out stating the below:

Error: A method named '/BasicCollection/insert' is already defined

Right now I’m confused as to where to declare these?

Thanks.