Hello there,
i’m new to both, mongo and meteor/node.js, so sry for this kind of stupid question - i’m trying to create a small blog for practice.
I already googled around bu found different solutions and wonder which one is the way to go.
I want to create categories(_id,…) and posts which belong to these categories.
- So the SQL way to do it would be posts(_id, category_id,…)
^^ i could find this kind of implementation in some meteor tutorials like here: http://meteortips.com/second-meteor-tutorial/methods-part-2/ - But it seems like a lot of people instead use sth. like categories(_id,…,collection(posts))
So which is the better way to go?
I tried to implement the first one but am struggeling with a rather simple task i think: getting the current categories id.
What i did is:
-
following the route
Router.route(’/categories/:_id’, {
name: ‘app_view’,
template: ‘app_view’,
data: function(){
var currentCategory = this.params._id;
return Categories.findOne({ _id: currentCategory });
}
});
\3. Displaying a form for posts
{{> quickForm collection=“Posts” id=“insertPostForm” type=“insert”}}
using the following schema:
Schemas.Posts = new SimpleSchema({
...,
category_id: {
type: String,
autoValue: function(){
//return this._id;
},
autoform: { type: "hidden", label: false }
}
});
How do i get the currently selected category _id here?
Regards,
thx for any help,
lukas