Vulcan/packages/example-interfaces/lib/modules/categories/views.js
ochicf 2c6526f81f Added example-interfaces package
Shows how to use a simple a hierarchical interface implemented in a Categories collection.
2017-07-22 11:37:06 +02:00

36 lines
676 B
JavaScript

import Categories from './collection.js';
// will be common to all other view unless specific properties are overwritten
Categories.addDefaultView(function (terms) {
return {
options: {
sort: { name: 1 },
limit: 1000,
}
};
});
Categories.addView("childrenCategories", function (terms) {
return {
selector: {
parentId: terms.parentId,
},
options: {
sort: { name: 1 },
}
};
});
Categories.addView("topLevelCategories", function (terms) {
return {
selector: {
$or: [
{ parentId: null },
{ parentId: { $exists: false } },
],
},
options: {
sort: { name: 1 },
}
};
});