Json imported database not showing on the client with select2


I created a scheme using Aldeed node-simpl-schema and attached it to a collection that I populated with almost 40.000 entries parse from a JSON database using the following command:mongoimport -h localhost:3001 --db meteor --collection myCollection --type json --file myFile.json --jsonArray. The import worked well I can query the database from the console (meteor mongo). I can also present the database to the client using Aldeed tabular package. But for some reasons I can’t fetch the data from another collection using select2. Here is the code:

state: {
        type: Array,
        label: 'State',
        autoform: {
            type: 'select2',
            afFieldInput: {
                multiple: false,
                select2Options: {
                    placeholder: 'Choose a State',
                    tags: true,
                    style: "width: 50%",
                    closeOnSelect: true
                options: function() { 
                    return Countries.find({ state: { $exists: true, $ne: [] } }, { fields: { state: 1 } }).map(function(c) {
                        return {
                            label: c.state,
                            value: c._id

    'state.$': String,

For some reason, this code doesn’t return anything. Although the countries database has more than 40.000 entries.
Any help will be welcome.


Are you subscribing to the data?


Yes i do.
Server - main.js

Meteor.publish('countries', function() {
    return Countries.find();


Template.myTemplateName.onCreated(function() {


Have you tried querying the data from the web console? Try just a plain


in the browser console and see if there is anything there to begin with.

Also try putting a limit on the publication, 40k is a lot to publish all at once.


@jpmoyn yes. I tried querying from the console and I can get the data back. I limit the publication to 50 and also limit the subscription to 50. When testing with Handlebars:

{{#if Template.subscriptionsReady}}
       {{#each countries}} 
        <div class="loading">loading...</div>

all the 50 data are shown without problems. But for some reason, select2 is not showing anything. But when populating the countries database directly from the client (Using autoform for ex.) the data are shown in select2.


Could this be down to the _ids? By default Meteor uses strings, but mongoimport generates ObjectIds.


@robfallows I think you are right. I just look it up and the _ids are in the form "_id" : ObjectId("59381e92cf09d6e8c1bb35e8"), Maybe there is a better way to import data from JSON file or even reading directly from it.


I finally solved this by using JSON.parse(Assets.getText('file.json')) on server startup ( Meteor.startup(() => {...}); ). Hope this help someone.