Vulcan/packages/nova-comments/lib/views.js
2016-04-09 09:41:20 +09:00

35 lines
No EOL
936 B
JavaScript

/**
* @summary Comment views are filters used for subscribing to and viewing comments
* @namespace Comments.views
*/
Comments.views = {};
/**
* @summary Add a module to a comment view
* @param {string} viewName - The name of the view
* @param {function} [viewFunction] - The function used to calculate query terms. Takes terms and baseParameters arguments
*/
Comments.views.add = function (viewName, viewFunction) {
Comments.views[viewName] = viewFunction;
};
// will be common to all other view unless specific properties are overwritten
Comments.views.baseParameters = {
options: {
limit: 10
}
};
Comments.views.add("postComments", function (terms) {
return {
selector: {postId: terms.postId},
options: {limit: 0, sort: {score: -1, postedAt: -1}}
};
});
Comments.views.add("userComments", function (terms) {
return {
selector: {userId: terms.userId},
options: {sort: {postedAt: -1}}
};
});