mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-03-01 05:29:41 +00:00
Adding more models
This commit is contained in:
parent
adc4309951
commit
bbf324ea83
27 changed files with 885 additions and 1 deletions
40
server/models/Book.js
Normal file
40
server/models/Book.js
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
const { DataTypes, Model } = require('sequelize')
|
||||
|
||||
module.exports = (sequelize) => {
|
||||
class Book extends Model { }
|
||||
|
||||
Book.init({
|
||||
id: {
|
||||
type: DataTypes.UUID,
|
||||
defaultValue: DataTypes.UUIDV4,
|
||||
primaryKey: true
|
||||
},
|
||||
title: DataTypes.STRING,
|
||||
subtitle: DataTypes.STRING,
|
||||
publishedYear: DataTypes.STRING,
|
||||
publishedDate: DataTypes.STRING,
|
||||
publisher: DataTypes.STRING,
|
||||
description: DataTypes.TEXT,
|
||||
isbn: DataTypes.STRING,
|
||||
asin: DataTypes.STRING,
|
||||
language: DataTypes.STRING,
|
||||
explicit: DataTypes.BOOLEAN,
|
||||
lastCoverSearchQuery: DataTypes.STRING,
|
||||
lastCoverSearch: DataTypes.DATE
|
||||
}, {
|
||||
sequelize,
|
||||
modelName: 'Book'
|
||||
})
|
||||
|
||||
const { LibraryItem, FileMetadata, EBookFile } = sequelize.models
|
||||
LibraryItem.hasOne(Book)
|
||||
Book.belongsTo(LibraryItem)
|
||||
|
||||
FileMetadata.hasOne(Book)
|
||||
Book.belongsTo(FileMetadata, { as: 'ImageFile' }) // Ref: https://sequelize.org/docs/v6/core-concepts/assocs/#defining-an-alias
|
||||
|
||||
EBookFile.hasOne(Book)
|
||||
Book.belongsTo(EBookFile)
|
||||
|
||||
return Book
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue