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