-
Notifications
You must be signed in to change notification settings - Fork 5.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple Collection Reactive Join #147
Comments
The last thing is not true, since you have set data-dishid you can access it. Other than that, I think it would be nice to be able to do something like |
The problem is that I use the same dish._id in multiple places. So yes I can tell which dish, but not for which Customer or by which Chef, which is the main goal. |
Uhm, you can...
|
@TomWij / Yes, you can do that when it is a reaction to a mouseclick. But it doesn't work when it's a helper for example to determine if a css classname is added to a tag for example since {{serving}} isn't passed an event object.
<div class='servethis {{serving}}'>Serve {{name}}</div> |
In a template, the Handlebars In an event handler, there isn't a great way to do this at present. If you want to get the data for a node besides the event target, the function you want is findEventData in packages/liveui/liveui.js. It's a local, inaccessible function, but everything it uses is accessible. |
@dgreensp Thanks, that's an interesting approach. Let me see how far that gets me. |
@pctj101 Did handlebars |
I'm closing this for now, but @pctj101 if that doesn't work, comment here about what happened and I'll reopen this. |
Having template
outputs parentItem properties |
Thank you spastai |
Update coveralls to version 2.11.9 🚀
The environment variable name MONGO_URL was updated to MONGO_OPLOG_URL
Say I have a few collections:
Chefs
Customers
Dishes
And for each day in my schedule, I need to remember which Chef, is cooking which Dish, for which Customer.
I want to display it like a battleship grid...
Day XYZ
Chef #1
Grid
X axis - Customer
Y axis - Dish
Chef #2
Grid
X axis - Customer
Y axis - Dish
I'm going to use a few templates like:
Template: home
{{#each chefs}}
{{>chef}}
{{/each}}
Template: chef
{{#each customers}}
{{> customer}}
{{/each}}
Template: customer
{{#each dishes}}
{{> dish}}
{{/each}}
Template: dish
Well.. by the time I click .servethis, that template has no idea what 'customer' or 'chef' it exists under.
We can pass the chef._id and customer.id into the template using a helper and modifying the dish to include:
dishes = _.map(dishes, function(dish) { return {dish: dish, customer_id = customer.id, chef_id = chef.id}; } );
But now dishes is an Array, not a reactive Collection.... which presents a problem when Customers.find() returns 0 results at first, then 10 results later for example. So it seems modifying the return value of find() is not a good idea when directly used as a template helper.
Alternatively we can cure this by using a single Collection called ChefsCustomerDishes. However to loop this, we'd need to pre-create all the objects for every possible combination of at least Chef + Customer, leaving only the Dish attribute unknown. Otherwise, without pre-creating these objects, there would be nothing for mustache to loop through.
This is particularly problematic when you factor in dates... because precreating all these records for all dates just for the sake of display doesn't seem like the optimal approach.
I've considered using jQuery to suck out all the _id's from the DOM. For example:
But then I realized that using jQuery to extract my function variables seemed a bit suboptimal.
However, even with that solution it leaves the helpers abandoned.. for example
Perhaps there's a better way?
The text was updated successfully, but these errors were encountered: