bootstrap-server-data-model
Version:
Data model for Emiand's bootstrap server.
50 lines (42 loc) • 1 kB
JavaScript
class AbstractNode {
constructor() {
this.name = "";
this.id = -1;
this.createDate = new Date();
}
getCreateDate(format) {
switch(format) {
case "MM-DD-YYYY":
return this.createDate.getMonth() + '-' + this.createDate.getDate() + '-' + this.createDate.getFullYear();
case "DD-MM-YYYY":
return this.createDate.getDate() + '-' + this.createDate.getMonth() + '-' + this.createDate.getFullYear();
default:
return this.createDate.getTime();
}
}
getId() {
return this.id;
}
getName() {
return this.name;
}
setId(id) {
this.id = id;
}
setName(name) {
this.name = name;
}
inflate(data) {
this.id = id;
this.name = data.name;
this.createDate = data.createDate;
}
toString() {
return JSON.stringify({
name: this.getName(),
id: this.getId(),
createDate: getCreateDate()
});
}
}
module.exports = AbstractNode;