sub-manager-backend/objects/Submission.mjs

52 lines
1.7 KiB
JavaScript
Raw Normal View History

2023-09-07 10:07:34 +00:00
import Entity from "./Entity.mjs";
import dataValidation from "./dataValidation.mjs";
2023-09-07 10:07:34 +00:00
export default class Submission extends Entity{
set _story_id(prop){
if(prop){
2023-09-14 14:06:17 +00:00
const propNumber = Number.parseInt(prop)
if(Number.isNaN(propNumber)){throw new TypeError("story_id must be an integer")}
2023-09-11 22:00:39 +00:00
this.story_id=propNumber
}
}
set _pub_id(prop){
2023-09-14 14:06:17 +00:00
const propNumber = Number.parseInt(prop)
if(prop){
2023-09-14 14:06:17 +00:00
if(Number.isNaN(propNumber)){throw new TypeError("pub_id must be an integer")}
2023-09-11 22:00:39 +00:00
this.pub_id=propNumber
}
}
set _response_id(prop){
if(prop){
2023-09-14 14:06:17 +00:00
const propNumber = Number.parseInt(prop)
if(Number.isNaN(propNumber)){throw new TypeError("response_id must be an integer")}
2023-09-11 22:00:39 +00:00
this.response_id=propNumber
}
}
set _date_submitted(prop){
if(prop){
if(!dataValidation.dateStringIsValid(prop)){throw new TypeError("response_id must be a valid date in YYYY-MM-DD format")}
this.date_submitted=prop
}
}
set _date_responded(prop){
if(prop){
if(!dataValidation.dateStringIsValid(prop)){throw new TypeError("date_responded must be a valid date in YYYY-MM-DD format")}
this.date_responded=prop
}
}
2023-09-09 14:04:53 +00:00
get table(){
return 'subs'
}
2023-11-13 11:09:47 +00:00
get idName(){
return 'sub_id'
}
2023-09-07 10:07:34 +00:00
constructor(data){
super(data)
this._story_id=data?.story_id
this._pub_id=data?.pub_id
this._response_id=data?.response_id
this._date_submitted=data?.date_submitted
this._date_responded=data?.date_responded
2023-09-07 10:07:34 +00:00
}
}