Vulcan/packages/telescope-comments/lib/comments.js

97 lines
1.7 KiB
JavaScript
Raw Normal View History

2015-04-24 09:28:50 +09:00
/**
* The global namespace for Comments.
* @namespace Comments
*/
Comments = new Mongo.Collection("comments");
/**
* Comments schema
* @type {SimpleSchema}
*/
Telescope.schemas.comments = new SimpleSchema({
2015-04-22 07:50:26 +09:00
_id: {
type: String,
optional: true
},
parentCommentId: {
type: String,
optional: true
2015-04-22 07:50:26 +09:00
},
createdAt: {
type: Date,
optional: true
},
postedAt: { // for now, comments are always created and posted at the same time
type: Date,
optional: true
},
body: {
type: String,
editableBy: ["member", "admin"],
2015-04-28 09:44:43 +09:00
autoform: {
rows: 5
}
2015-04-22 07:50:26 +09:00
},
htmlBody: {
type: String,
optional: true
},
baseScore: {
type: Number,
decimal: true,
optional: true
},
score: {
type: Number,
decimal: true,
optional: true
},
upvotes: {
type: Number,
optional: true
},
upvoters: {
type: [String],
2015-04-22 07:50:26 +09:00
optional: true
},
downvotes: {
type: Number,
optional: true
2015-04-22 07:50:26 +09:00
},
downvoters: {
type: [String],
2015-04-22 07:50:26 +09:00
optional: true
},
author: {
type: String,
optional: true
},
inactive: {
type: Boolean,
optional: true
},
postId: {
2015-04-28 09:44:43 +09:00
type: String,
optional: true,
editableBy: ["member", "admin"], // TODO: should users be able to set postId, but not modify it?
autoform: {
omit: true // never show this
}
2015-04-22 07:50:26 +09:00
},
userId: {
2015-04-28 09:44:43 +09:00
type: String,
2015-04-22 07:50:26 +09:00
optional: true
},
isDeleted: {
type: Boolean,
optional: true
}
});
Telescope.schemas.comments.internationalize();
Comments.attachSchema(Telescope.schemas.comments);
2015-04-22 07:50:26 +09:00
Comments.allow({
update: _.partial(Telescope.allowCheck, Comments),
remove: _.partial(Telescope.allowCheck, Comments)
});