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

33 lines
830 B
JavaScript
Raw Normal View History

2015-05-08 09:20:58 +09:00
/**
* Comment views are filters used for subscribing to and viewing comments
* @namespace Comments.views
*/
Comments.views = {};
/**
* 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.register = 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.register("postComments", function (terms) {
return {
find: {postId: terms.postId}
};
});
Comments.views.register("userComments", function (terms) {
return {
find: {userId: terms.userId}
};
});