start support for songs
This commit is contained in:
24
def/songs.js
Normal file
24
def/songs.js
Normal file
@@ -0,0 +1,24 @@
|
||||
class Songs {
|
||||
constructor(info) {
|
||||
if (!info || !info.userid) throw "Can not construct empty profile";
|
||||
this.userid = info.userid;
|
||||
this.data = info.data || {};
|
||||
|
||||
const allowedParams = ["title", 'author', "content", "contentHistory", "bpm", "lang", "reactions", "root", 'beatsPerTempo'];
|
||||
for (const key in info) {
|
||||
if (info.hasOwnProperty(key) && allowedParams.includes(key)) {
|
||||
this[key] = info[key];
|
||||
}
|
||||
}
|
||||
this.createdAt = info.createdAt || new Date();
|
||||
this.lastUpdated = info.lastUpdated || this.createdAt;
|
||||
this.comments = info.comments || [];
|
||||
this.reactions = info.reactions || {};
|
||||
}
|
||||
|
||||
toObj() {
|
||||
return { ...this };
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Songs;
|
||||
Reference in New Issue
Block a user