Datas from collection in Javascript

Hello there.

I’m pretty new to Meteor but as a web designer, it looks awesome and easy for me to understand. There is ton of help all over the Internet and so far, I’ve been able to build a website with an admin panel, which was unbelievable before with PHP or whatever.

But now, I’m stuck and I can’t find actual hints anywhere.
So here I am coming to you guys.

I understood how to pass data from collections within a helper and inject them into html with handlebars ( so cool >< ).
But now, I want to do the same in Javascript.
Let me explain :

I have FlowRouter and I want to store parameters into a collection so that my routes configuration won’t have repeated code, but something dynamic.
Here comes my imports/startup/client/

{ Meteor } = require 'meteor/meteor'

handle = Meteor.subscribe('routes')
Routes.find {}

FlowRouter.route 'routePath',
  triggersEnter: [ ->
    Meteor.defer ->
      $('sectionAddClass').addClass 'classEffect'
  action: (params, queryParams) ->
    BlazeLayout.render 'mainLayout', mainContainer: 'mainContainer'
  name: 'routeName'
  title: 'routeTitle'

I think there is something to do with cursor, foreach or whatever but I don’t understand right now how javascript is dealing with collection’s data in this particular way. I understand this is a pretty lame question but as a designer I’m trying to do my best to get it and sometimes, it’s sounds really harsh.

Any hint would be appreciated!
Thanks guys.

Unfortunately, I don’t use coffee, so I can’t really follow your code to see what you expect to happen. However, unless coffee is doing something magical I don’t understand, you have a Routes.find which returns a cursor, but then throws it away (I would expect to see something like const allRoutes = Routes.find({}) in ES2015 and then do something with allRoutes). Also, you are not waiting for your routes cursor to load (over the wire), so in all likelihood it will be empty unless you introduce some reactive context to defer processing until data’s available.

I’d love to know your secret when it comes to answering forum posts then @robfallows; I need a LOT of coffee!

1 Like