Skip to content
Snippets Groups Projects
Commit dc9e2e93 authored by michael.minelli's avatar michael.minelli
Browse files

Models => Add enonce and enonceStaff

parent 7d2f3798
No related branches found
No related tags found
No related merge requests found
import Model from './Model';
import db from '../helpers/DatabaseHelper';
class Enonce extends Model {
static tableName: string = 'Enonce';
enonceID: number = null;
enonceName: string = '';
enonceGitlabId: number = null;
enonceGitlabLink: string = '';
enonceGitlabCreationInfo: string = '';
enonceGitlabLastInfo: string = '';
enonceGitlabLastInfoTs: number = null;
public async toJsonObject(lightVersion: boolean): Promise<Object> {
const result = {
'id' : this.enonceID,
'name' : this.enonceName,
'gitlabId' : this.enonceGitlabId,
'gitlabLink' : this.enonceGitlabLink,
'gitlabCreationInfo': this.enonceGitlabCreationInfo,
'gitlabLastInfo' : this.enonceGitlabLastInfo,
'gitlabLastInfoTs' : this.enonceGitlabLastInfoTs
};
return result;
};
public importFromJsonObject(jsonObject: any) {
this.enonceID = jsonObject.id;
this.enonceName = jsonObject.name;
this.enonceGitlabId = jsonObject.gitlabId;
this.enonceGitlabLink = jsonObject.gitlabLink;
this.enonceGitlabCreationInfo = jsonObject.gitlabCreationInfo;
this.enonceGitlabLastInfo = jsonObject.gitlabLastInfo;
this.enonceGitlabLastInfoTs = jsonObject.gitlabLastInfoTs;
}
public toDb(): any {
return {
enonceName : this.enonceName,
enonceGitlabId : this.enonceGitlabId,
enonceGitlabLink : this.enonceGitlabLink,
enonceGitlabCreationInfo: this.enonceGitlabCreationInfo,
enonceGitlabLastInfo : this.enonceGitlabLastInfo,
enonceGitlabLastInfoTs : this.enonceGitlabLastInfoTs
};
}
async create(): Promise<void> {
const id = await db(Enonce.tableName).insert(this.toDb());
this.enonceID = id[0];
}
update(): Promise<void> {
return db(Enonce.tableName).where('enonceID', this.enonceID).update(this.toDb());
}
del(): Promise<void> {
return db(Enonce.tableName).where('enonceID', this.enonceID).del();
}
}
export default Enonce;
import Model from './Model';
import db from '../helpers/DatabaseHelper';
class EnonceStaff extends Model {
static tableName: string = 'EnonceStaff';
enonceID: number = null;
userID: number = null;
public async toJsonObject(lightVersion: boolean): Promise<Object> {
const result = {
'enonceID': this.enonceID,
'userID' : this.userID
};
return result;
};
public importFromJsonObject(jsonObject: any) {
this.enonceID = jsonObject.enonceID;
this.userID = jsonObject.userID;
}
public toDb(): any {
return {
enonceID: this.enonceID,
userID : this.userID
};
}
create(): Promise<void> {
return db(EnonceStaff.tableName).insert(this.toDb());
}
del(): Promise<void> {
return db(EnonceStaff.tableName).where('enonceID', this.enonceID).andWhere('userID', this.userID).del();
}
}
export default EnonceStaff;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment