menuserver/server/lib/FoodObj.js
Martin Donnelly a4ebf90586 Added new note type
Better authentication
2020-03-21 21:22:12 +00:00

40 lines
694 B
JavaScript

class FoodObj {
constructor(limit) {
this.limit = limit;
this.store = [];
this.types = [0, 0, 0, 0, 0, 0, 0];
}
get () {
return this.store;
}
getFirstFive() {
return (this.store.slice(0, 5));
}
getFirstFiveIDs() {
const outVal = this.store.slice(0, 5).map((item) => {
return item._id;
});
return (outVal);
}
add(item) {
// console.log('>>', item);
item.url = `https://menu.silvrtree.co.uk/view/${item.short}`;
if (this.types[item.meat] < this.limit) {
this.store.push(item);
this.types[item.meat]++;
}
}
count() {
return (this.store.slice(0, 5).length);
}
}
module.exports = FoodObj;