How to get collection in some meteor package when I know only collection name?
In app:
import {doIt} from 'meteor/some:package'
doIt('CoolCollection')
In package:
export const doIt = (collection_name) => {
// This worked before, but now collection is not in global scope
const collection = global[collection_name]
...
}
I know I could add collection into global
but it doesn’t look right for me.
// /lib/collections.js
import { Mongo } from 'meteor/mongo'
export const CoolCollection = new Mongo.Collection('CoolCollection')
global.CoolCollection = CoolCollection // This solves problem, but doesn't sound right :/
My question on StackOverflow: