audiobookshelf/server/models/LibraryItem.js
2023-03-15 17:42:35 -05:00

34 lines
832 B
JavaScript

const { DataTypes, Model } = require('sequelize')
module.exports = (sequelize) => {
class LibraryItem extends Model { }
LibraryItem.init({
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true
},
ino: DataTypes.STRING,
path: DataTypes.STRING,
relPath: DataTypes.STRING,
mediaType: DataTypes.STRING,
isFile: DataTypes.BOOLEAN,
isMissing: DataTypes.BOOLEAN,
isInvalid: DataTypes.BOOLEAN,
mtime: DataTypes.DATE(6),
ctime: DataTypes.DATE(6),
birthtime: DataTypes.DATE(6),
lastScan: DataTypes.DATE,
lastScanVersion: DataTypes.STRING
}, {
sequelize,
modelName: 'LibraryItem'
})
const { LibraryFolder } = sequelize.models
LibraryFolder.hasMany(LibraryItem)
LibraryItem.belongsTo(LibraryFolder)
return LibraryItem
}