1
0

mediaItem.js 937 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. const DatabaseModel = require("./DatabaseModel.js").DatabaseModel;
  2. function MediaFileModel() {
  3. DatabaseModel.call(this);
  4. this.path = "";
  5. this.md5sum = "";
  6. }
  7. MediaFileModel.prototype = Object.create(DatabaseModel.prototype);
  8. MediaFileModel.prototype.getTableName = function() {
  9. return "mediaFile";
  10. }
  11. MediaFileModel.prototype.createOrUpdateBase = async function(dbHelper) {
  12. await dbHelper.runSql(`CREATE TABLE IF NOT EXISTS 'mediaFile' (
  13. path STRING NOT NULL,
  14. md5sum varchar(32) NOT NULL,
  15. PRIMARY KEY (path, md5sum))`);
  16. }
  17. MediaFileModel.prototype.describe = function() {
  18. return {
  19. "path": this.path,
  20. "md5sum": this.md5sum
  21. };
  22. }
  23. MediaFileModel.prototype.versionColumn = function() { return ""; }
  24. MediaFileModel.prototype.fromDb = function(dbObj) {
  25. this.path = dbObj["path"];
  26. this.md5sum = dbObj["md5sum"];
  27. }
  28. module.exports.MediaFileModel = MediaFileModel;