Skip to content

Instantly share code, notes, and snippets.

@AlexeyMK
Created May 8, 2017 00:25
Show Gist options
  • Save AlexeyMK/84ed89aaa30da0aea9170974f038955e to your computer and use it in GitHub Desktop.
Save AlexeyMK/84ed89aaa30da0aea9170974f038955e to your computer and use it in GitHub Desktop.
original implementation of exposing collections dynamically
# https://github.com/gterrono/houston/blob/4ec16866346abc1b08e761d62441a56fd93a7e99/server/list_view.coffee
Dummy = new Meteor.Collection("system.dummy") # hack.
collections = {}
Meteor.startup( ->
console.log collections
Dummy.findOne() # hack
Meteor._RemoteCollectionDriver.mongo.db.collections (meh, collections) ->
collection_names = (col.collectionName for col in collections \
when (col.collectionName.indexOf "system.") isnt 0)
for name in collection_names
if name not in collections
collections[name] = new Meteor.Collection(name)
# TODO admin user only
Meteor.publish "admin_#{name}", -> collections[name].find({})
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment