add schema gneerator for activity.js
This commit is contained in:
parent
79146983da
commit
048b42f6cd
1 changed files with 22 additions and 0 deletions
|
@ -9,6 +9,28 @@ class Activity extends Entry {
|
||||||
constructor(PROPERTIES) {
|
constructor(PROPERTIES) {
|
||||||
super(PROPERTIES);
|
super(PROPERTIES);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
Generate a schema for MongoDB.
|
||||||
|
|
||||||
|
@return {OBJECT} the schema
|
||||||
|
*/
|
||||||
|
static generateTemplate() {
|
||||||
|
let SCHEMA = {
|
||||||
|
"username": {"type": String, "required": true},
|
||||||
|
"description": {"type": String},
|
||||||
|
"date": {"type": Number},
|
||||||
|
"duration": {"type": Number}
|
||||||
|
}
|
||||||
|
let TEST = new Activity();
|
||||||
|
|
||||||
|
// Verify that the schema is valid.
|
||||||
|
Object.keys(SCHEMA).forEach((KEY) => {
|
||||||
|
if (!Object.keys(TEST).includes(KEY)) {delete SCHEMA[KEY];};
|
||||||
|
});
|
||||||
|
|
||||||
|
return (SCHEMA)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Activity;
|
module.exports = Activity;
|
Loading…
Add table
Add a link
Reference in a new issue