| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- const DatabaseModel = require("./DatabaseModel.js").DatabaseModel;
- function MediaFileModel() {
- DatabaseModel.call(this);
- this.path = "";
- this.md5sum = "";
- this.fixedSum = "";
- this.date = null;
- }
- MediaFileModel.prototype = Object.create(DatabaseModel.prototype);
- MediaFileModel.prototype.getTableName = function() {
- return "mediaFile";
- }
- MediaFileModel.prototype.createOrUpdateBase = async function(dbHelper) {
- await dbHelper.runSql(`CREATE TABLE IF NOT EXISTS 'mediaFile' (
- path STRING NOT NULL,
- md5sum varchar(32) NOT NULL,
- fixedSum varchar(32) NOT NULL,
- date DateTime NOT NULL,
- PRIMARY KEY (path, md5sum))`);
- }
- MediaFileModel.prototype.describe = function() {
- return {
- "path": this.path,
- "md5sum": this.md5sum,
- "fixedSum": this.fixedSum,
- "date": this.date?.getTime()
- };
- }
- MediaFileModel.prototype.versionColumn = function() { return ""; }
- MediaFileModel.prototype.fromDb = function(dbObj) {
- this.path = dbObj["path"];
- this.md5sum = dbObj["md5sum"];
- this.fixedSum = dbObj["fixedSum"];
- this.date = new Date(dbObj["date"]);
- }
- module.exports.MediaFileModel = MediaFileModel;
|