Es2015 minimongo


Hello, I have a file structure the same as the recommended from the styleguide, in my imports folder I have a collections folder with index.js with this content:

import { Mongo } from 'meteor/mongo';

export const Visitors = new Mongo.Collection('visitors');
export const Gabinetes = new Mongo.Collection('gabinetes');
export const History = new Mongo.Collection('history');

in my client/index.js I have these contents

import '/imports/startup/router';
import { Visitors, Gabinetes, History } from '/imports/collections';

export { Visitors, Gabinetes, History };

but in my js console I can’t see any collection to use, how can I manage minimongo collections using modules?


You can either make them available globally in dev mode:

if (process.env.NODE_ENV === 'development') {
  global.db = {Visitors, Gabinetes, History};

or import them in the console:

Visitors = require('./imports/collections').Visitors;


I didn’t knew that you could use require in the browser. that’s cool, but I thought the insecure package already did the global naming


It’s a Meteor feature

AFAIK the insecure package just allows you to make database calls from the client

import { Visitors as _Visitors } from '/imports/collections';
Vistors = _Visitors

import { Gabinetes as _Gabinetes } from '/imports/collections';
Gabinetes = _Gabinetes

import { History as _History } from '/imports/collections';
History = _History