const DatabaseModel = require("./DatabaseModel.js").DatabaseModel; function ApiKeyModel(privId, ipAddress) { this.created = new Date(); this.ipAddress = ipAddress; this.apiKey = privId; } Object.setPrototypeOf(ApiKeyModel.prototype, DatabaseModel.prototype); ApiKeyModel.prototype.getTableName = function() { return "apiKey"; } ApiKeyModel.prototype.createOrUpdateBase = async function(dbHelper) { await dbHelper.runSql(`CREATE TABLE IF NOT EXISTS 'apiKey' ( created datetime not null, apiKey string, ipAddress string )`); } ApiKeyModel.prototype.describe = function() { return { "ipAddress": this.ipAddress, "created": this.created.getTime(), "apiKey": this.apiKey }; } ApiKeyModel.prototype.fromDb = function(dbObj) { this.created = new Date(dbObj['created']); this.ipAddress = dbObj['ipAddress']; this.apiKey = dbObj['apiKey']; } module.exports.ApiKeyModel = ApiKeyModel;