autotag.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. const DatabaseModel = require("./DatabaseModel.js").DatabaseModel;
  2. const AUTOTAG_TYPE = {
  3. path: 0,
  4. meta: 1
  5. };
  6. function AutotagModel() {
  7. DatabaseModel.call(this);
  8. this.id = null;
  9. this.type = AUTOTAG_TYPE.path;
  10. this.typeData = "";
  11. this.tag = "";
  12. }
  13. AutotagModel.prototype = Object.create(DatabaseModel.prototype);
  14. AutotagModel.prototype.getTableName = function() {
  15. return "autotag";
  16. }
  17. AutotagModel.prototype.createOrUpdateBase = async function(dbHelper) {
  18. await dbHelper.runSql(`CREATE TABLE IF NOT EXISTS 'autotag' (
  19. id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
  20. type TINYINT NOT NULL,
  21. typeData STRING NOT NULL,
  22. tag STRING NOT NULL
  23. )`);
  24. }
  25. AutotagModel.prototype.describe = function() {
  26. return {
  27. "id": this.id,
  28. "type": this.type,
  29. "typeData": this.typeData,
  30. "tag": this.tag
  31. };
  32. }
  33. AutotagModel.prototype.versionColumn = function() { return ""; }
  34. AutotagModel.prototype.fromDb = function(dbObj) {
  35. this.id = dbObj["id"];
  36. this.type = dbObj["type"];
  37. this.typeData = dbObj["typeData"];
  38. this.tag = dbObj["tag"];
  39. }
  40. module.exports.AutotagModel = AutotagModel;
  41. module.exports.AUTOTAG_TYPE = AUTOTAG_TYPE;