Files
DiceCloud/rpg-docs/Routes/Routes.js
Thaum ca7a625534 Consolidated all sub-documents into character document to improve granularity significantly
Because just the top-level field changing invalidates everything in the sub-document, a single attribute change would trigger a re-calculation on all attributes and their dependents. This change should significantly improve performance.
2014-11-20 09:02:10 +00:00

47 lines
1022 B
JavaScript

Router.map( function () {
this.route('home',
{
path: '/',
waitOn: function(){
return Meteor.subscribe("characterList", Meteor.userId());
},
data: {
characters: function(){
return Characters.find({}, {fields: {_id: 1}});
}
}
});
this.route('character', {
path: '/character/:_id',
notFoundTemplate: 'characterNotFound',
waitOn: function(){
return Meteor.subscribe("singleCharacter", this.params._id, Meteor.userId());
},
data: function() {
var data = Characters.findOne({_id: this.params._id}, {fields: {_id: 1}});
return data;
}
});
this.route('inventory', {
path: '/inventory/:_id',
notFoundTemplate: 'characterNotFound',
data: {
containers: function() {
var containers = Containers.find({owner: data._id}, {fields: {_id: 1}});
return containers;
},
}
});
this.route('item', {
path: '/item/:_id',
notFoundTemplate: 'itemNotFound',
data: function() {
var data = Items.findOne({_id: this.params._id});
return data;
}
});
});