const DatabaseModel = require("./DatabaseModel.js").DatabaseModel; const TYPE = { unknown: 0, ldapAccount: 1, email: 2, link: 3 }; const ACCESS_TO = { unknown: 0, item: 1, tag: 2, meta: 3 }; const GRANT = { none: 0, read: 1, write: 2 }; function AccessModel() { DatabaseModel.call(this); this.id = null; this.type = TYPE.unknown; this.typeData = ""; this.accessTo = ACCESS_TO.unknown; this.accessToData = ""; this.grant = GRANT.none; } AccessModel.prototype = Object.create(DatabaseModel.prototype); AccessModel.prototype.getTableName = function() { return "access"; } AccessModel.prototype.createOrUpdateBase = async function(dbHelper) { await dbHelper.runSql(`CREATE TABLE IF NOT EXISTS 'access' ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, type TINYINT NOT NULL, typeData STRING NOT NULL, accessTo TINYINT NOT NULL, accessToData STRING NOT NULL, grant TINYINT NOT NULL )`); } AccessModel.prototype.describe = function() { return { "id": this.id, "type": this.type, "typeData": this.typeData, "accessTo": this.accessTo, "accessToData": this.accessToData, "grant": this.grant }; } AccessModel.prototype.versionColumn = function() { return ""; } AccessModel.prototype.fromDb = function(dbObj) { this.id = dbObj["sessionId"]; this.type = dbObj["type"]; this.typeData = dbObj["typeData"]; this.accessTo = dbObj["accessTo"]; this.accessToData = dbObj["accessToData"]; this.grant = dbObj["grant"]; } module.exports.AccessModel = AccessModel;