To create a local collection pass 'null' to the meteor collection constructor:
import { Mongo } from 'meteor/mongo'; export const Meals = new Mongo.Collection(null);
Now, for example, when a recipe is dropped into the meal, a mongo update can be executed which will modify the document in memory:
interact('.orderDetailsPart .dropzone').dropzone({ ondrop: function (event) { var mealId = $(event.target).data('id'); var meal = Meals.findOne(mealId); var recipeId = $(event.relatedTarget).data('id'); var recipeId = Recipes.findOne(recipeId); meal.items.push({ id: recipeId , name: recipeId .name, type: 'recipe', imageUrl: recipeId .imageUrl }); Meals.update(mealId, meal); } });
The local collection is reactive so any changes done to it will automatically be detected and any UI element that is bound to it will be updated. You can checkout the source up to this point by using this commit or visit the live demo.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.