added data model and user model

This commit is contained in:
Mohammed Ashab Uddin
2020-07-21 13:58:04 +04:00
parent 95dc1ae218
commit 0efda2dc11
2 changed files with 93 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
const { User } = require("../models/user");
const { Website } = require("../models/website");
module.exports.data = new StructuredData();
class StructuredData {
constructor() {
this.data={};
}
addUser(id){
if(this.data[id] != undefined)
{
this.data[id] = new User(id);
return true
}
return false;
}
/**
*
* @param {number} id
* @returns {User}
*/
getUser(id){
return this.data[id];
}
deleteUser(id){
if(this.data[id] != undefined)
{
return delete this.data[id];
}
return false;
}
}
/*
data structured:
data = {
<id of user> : <Instance of User>,
<id of user> : <Instance of User>
}
*/