Vulcan/server/publish.js

89 lines
1.9 KiB
JavaScript
Raw Normal View History

2012-08-22 23:24:33 -04:00
// Posts
2012-08-22 21:27:22 -04:00
Posts = new Meteor.Collection('posts');
Meteor.publish('posts', function() {
return Posts.find();
});
2012-08-22 23:24:33 -04:00
Meteor.startup(function(){
Posts.allow({
2012-09-06 11:34:05 +09:00
insert: function(){
return true;
}
2012-09-06 11:09:24 +09:00
, update: function(userId, docs, fields, modifier){
console.log("Document's user: "+docs[0].user_id+" | Current user: "+userId);
if(docs[0].user_id && docs[0].user_id==userId){
return true;
}
return false;
}
2012-09-06 11:34:05 +09:00
, remove: function(userId, docs){
if(docs[0].user_id && docs[0].user_id==userId){
return true;
}
return false; }
2012-08-22 23:24:33 -04:00
});
});
// Comments
Comments = new Meteor.Collection('comments');
Meteor.publish('comments', function() {
return Comments.find();
});
Meteor.startup(function(){
Comments.allow({
2012-09-06 11:34:05 +09:00
insert: function(){
return true;
}
, update: function(userId, docs, fields, modifier){
console.log("Document's user: "+docs[0].user_id+" | Current user: "+userId);
if(docs[0].user_id && docs[0].user_id==userId){
return true;
}
return false;
}
, remove: function(userId, docs){
if(docs[0].user_id && docs[0].user_id==userId){
return true;
}
return false;
}
2012-08-30 21:35:48 -04:00
});
});
// MyVotes
MyVotes = new Meteor.Collection('myvotes');
Meteor.publish('myvotes', function() {
return MyVotes.find();
});
Meteor.startup(function(){
MyVotes.allow({
insert: function(){ return false; }
, update: function(){ return false; }
, remove: function(){ return false; }
2012-08-22 23:24:33 -04:00
});
});
2012-09-06 11:34:05 +09:00
// Options
Options = new Meteor.Collection('options');
Meteor.publish('options', function() {
return Options.find();
});
Meteor.startup(function(){
Options.allow({
insert: function(){ return false; }
, update: function(){ return false; }
, remove: function(){ return false; }
});
});