
const DatabaseModel = require("./DatabaseModel.js").DatabaseModel;

const AUTOTAG_TYPE = {
    path: 0,
    meta: 1
};

function AutotagModel() {
    DatabaseModel.call(this);
    this.id = null;
    this.type = AUTOTAG_TYPE.path;
    this.typeData = "";
    this.tag = "";
}

AutotagModel.prototype = Object.create(DatabaseModel.prototype);

AutotagModel.prototype.getTableName = function() {
    return "autotag";
}

AutotagModel.prototype.createOrUpdateBase = async function(dbHelper) {
    await dbHelper.runSql(`CREATE TABLE IF NOT EXISTS 'autotag' (
        id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
        type TINYINT NOT NULL,
        typeData STRING NOT NULL,
        tag STRING NOT NULL
        )`);
}

AutotagModel.prototype.describe = function() {
    return {
        "id": this.id,
        "type": this.type,
        "typeData": this.typeData,
        "tag": this.tag
    };
}

AutotagModel.prototype.versionColumn = function() { return ""; }

AutotagModel.prototype.fromDb = function(dbObj) {
    this.id = dbObj["id"];
    this.type = dbObj["type"];
    this.typeData = dbObj["typeData"];
    this.tag = dbObj["tag"];
}

module.exports.AutotagModel = AutotagModel;
module.exports.AUTOTAG_TYPE = AUTOTAG_TYPE;

