|
|
@@ -0,0 +1,64 @@
|
|
|
+
|
|
|
+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
|
|
|
+};
|
|
|
+
|
|
|
+function AccessModel() {
|
|
|
+ DatabaseModel.call(this);
|
|
|
+ this.id = null;
|
|
|
+ this.type = TYPE.unknown;
|
|
|
+ this.typeData = "";
|
|
|
+ this.accessTo = ACCESS_TO.unknown;
|
|
|
+ this.accessToData = "";
|
|
|
+}
|
|
|
+
|
|
|
+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
|
|
|
+ )`);
|
|
|
+}
|
|
|
+
|
|
|
+AccessModel.prototype.describe = function() {
|
|
|
+ return {
|
|
|
+ "id": this.id,
|
|
|
+ "type": this.type,
|
|
|
+ "typeData": this.typeData,
|
|
|
+ "accessTo": this.accessTo,
|
|
|
+ "accessToData": this.accessToData
|
|
|
+ };
|
|
|
+}
|
|
|
+
|
|
|
+AccessModel.prototype.versionColumn = function() { return "loginDateTime"; }
|
|
|
+
|
|
|
+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"];
|
|
|
+}
|
|
|
+
|
|
|
+module.exports.AccessModel = AccessModel;
|
|
|
+
|