node-rigorous
Version:
Rigorous Framework
22 lines (14 loc) • 397 B
JavaScript
module.exports = (attributes, filterLevel) => {
const filter = {
_id: 1,
created_at: 1,
updated_at: 1,
};
Object.keys(attributes).forEach((key) => {
const attributeFilter = attributes[key].filter.level;
if (attributeFilter <= filterLevel) {
filter[key] = 1;
}
});
return filter;
};