kannon/models/Environment.js

37 lines
809 B
JavaScript
Raw Permalink Normal View History

2022-06-03 17:04:44 +02:00
const path = require('path');
const { DataTypes } = require('sequelize');
const Base = require('./Base.js');
const tableName = path.basename(__filename, '.js').toLowerCase();
class Environment extends Base {
constructor(key, value) {
super();
this.tableName = tableName;
this.key = key;
this.value = value;
}
isValid() {
return this.key !== undefined;
}
async getModel() {
if (this.model === undefined) {
this.model = await database.connection.define(tableName, {
key: DataTypes.TEXT,
value: DataTypes.TEXT
},
{
freezeTableName: true
}
);
}
return this.model;
}
}
module.exports = Environment;