StructuredData uses entity to store data

This commit is contained in:
Mohammed Ashab Uddin
2020-07-22 10:43:52 +04:00
parent 1535d4cec0
commit 596f56b708

View File

@@ -1,21 +1,18 @@
const { Entity } = require("./entity");
const { User } = require("./user");
const { Website } = require("./website");
class StructuredData {
constructor() {
this.data={};
this.entity = new Entity();
}
addUser(id){
if(this.data[id] != undefined)
{
this.data[id] = new User(id);
return true
}
return false;
/**
* Adds a user
* @param {User} user
*/
addUser(user){
return this.entity.addData(user.id, user);
}
/**
@@ -24,17 +21,30 @@ class StructuredData {
* @returns {User}
*/
getUser(id){
return this.data[id];
return this.entity.getData(id);
}
/**
* Delete the user with a specific id
* @param {string} id
*/
deleteUser(id){
if(this.data[id] != undefined)
{
return delete this.data[id];
}
return false;
return this.entity.deleteData(id)
}
/**
* Check if a user with the given id exists
* @param {string} id
*/
isUser(id){
return this.entity.isData(id);
}
/**
* Clears all the data stored
*/
clearData(){
this.entity.clearData();
}