diff --git a/scripts/database/entry/log.JS b/scripts/database/entry/log.JS new file mode 100644 index 0000000..5d8d409 --- /dev/null +++ b/scripts/database/entry/log.JS @@ -0,0 +1,40 @@ +const Entry = require(`./object.JS`); + +class Log extends Entry { + // Default properties + name; + ID; + count; + activities; + + constructor(PROPERTIES) { + super(PROPERTIES); + this.calculate(); + } + + /* + Update and clean information. + */ + calculate () { + const set_activitiesCount = () => { + this.count = (this.activities instanceof Array) ? this.activities.length : 0; + }; + + const clean_activities = () => { + if ((this.activities instanceof Array) ? this.activities.length : false) { + for (let INDEX = 0; INDEX < this.activities.length ; INDEX++) { + [`username`].forEach((TBD) => { + if (Object.keys(this.activities[INDEX].includes(TBD))) { + delete this.activities[INDEX][TBD] + } + }) + } + } + } + + clean_activities(); + set_activitiesCount(); + } +} + +module.exports = Log; \ No newline at end of file