Skip to content

Instantly share code, notes, and snippets.

@czbaker
Last active August 29, 2015 14:23
Show Gist options
  • Select an option

  • Save czbaker/1d40faab052872899734 to your computer and use it in GitHub Desktop.

Select an option

Save czbaker/1d40faab052872899734 to your computer and use it in GitHub Desktop.
// Mod Follows
Follows = new Mongo.Collection("follows");
Follows.allow({
insert: function(userId, doc) {
return userId;
},
update: function(userId, doc) {
return false;
},
remove: function(userId, doc) {
return (userId && doc.owner === userId);
}
});
Schemas.Follows = new SimpleSchema({
owner: {
type: String,
autoValue: function() {
return this.userId;
}
},
entity: {
type: Number,
index: 1
},
uid: {
type: String
},
createdAt: {
type: Date,
defaultValue: new Date()
}
});
Follows.attachSchema(Schemas.Follows);
// Follow count of current mod
Meteor.publish('allFollowMod', function(mod) {
return Follows.find({uid: mod});
});
// Display single mod
Router.route('/mod/:id', function() {
this.render('modSingle');
}, {
name: 'modSingle',
waitOn: function() {
var user = Meteor.userId();
var mod = this.params.id;
return [
Subs.subscribe('singleMod', mod),
Subs.subscribe('modOwner', mod),
Subs.subscribe('currentModUser', user, mod),
Subs.subscribe('currentFollowMod', user, mod),
Subs.subscribe('allFollowMod', mod), // This one is causing the lockup.
Subs.subscribe('modScreens', mod),
Subs.subscribe('screenFiles'),
Subs.subscribe('modComments', mod),
Subs.subscribe('usernameEmail')
];
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment