Populate select2 schema from another collection

I’m using Aldeed node-simple-schema with autoform-select2 and collection2 I’ve created a Schema and attached it to a database called Country with 3 fields: country, state and city. I populated these with almost 30000 entries. Now I want to use simple-schema with select2 an read from this database and display it as select to the user.
Country collection

import SimpleSchema from 'simpl-schema';
SimpleSchema.extendOptions(['autoform']);
import { Tracker } from 'meteor/tracker';

Countries = new Mongo.Collection('countries');

Countries.allow({
    insert: () => false,
    update: () => false,
    remove: () => false
});

Countries.deny({
    insert: () => true,
    update: () => true,
    remove: () => true
});

Schemas = {};

Schemas.CountriesSchema = new SimpleSchema({

    country: {
        type: String,
        label: 'Country',
        autoform: {
            label: 'Country',
            type: 'text'
        }

    },
    state: {
        type: String,
        label: 'State',
        autoform: {
            label: 'State',
            type: 'text'
        }

    },
    city: {
        type: String,
        label: 'City',
        autoform: {
            label: 'City',
            type: 'text'
        }

    }

}, { tracker: Tracker });

Countries.attachSchema(Schemas.CountriesSchema);
...
country: {
        type: String,
        label: 'Country',
        autoform: {
            type: 'select2',
            afFieldInput: {
                multiple: false,
                select2Options: {
                    placeholder: 'Choose a Country',
                    tags: true,
                    style: "width: 50%",
                    allowClear: true,
                    closeOnSelect: false
                },
                options: function() {  // Fetch data from Country Collection and display on this field
                    return countries.find({ fields: { country: 1 } }).map(function(c) {
                        return {
                            label: c.title,
                            value: c._id
                        }
                    })
                }
            }
        }

    },
...

I don’t know if this is the best solution to achieve this. I would like to avoid using template helpers.

So funny, I literally just walked through this yesterday. I struggled with exactly what you are trying to do, and wasn’t able to find a solution without leaving the schema.

I toyed with the idea of controlling the load order of the schemas/collections so that I could generate a list of options before defining the schema, but that doesn’t really work when you’re adding/subtracting from the collection that defines the options anyway.

I ended up going with template helpers, as that seemed like the quick and dirty way to get reactive options working. Although I hated doing that as that automatically makes {{> quickForm}} a no go.

Definitely interested to see if anyone else got this going.

@vigorwebsolutions I’m happy I’m not the only one struggling with this. Just hope there will a Super-Man or a Super-Meteor out there that has/can solve this… :smiley: I tried to go with select2Options and ajax but no positive result. Will really be glad if anyone has ever done this…