audiobookshelf/server/models/Device.js

29 lines
733 B
JavaScript
Raw Normal View History

const { DataTypes, Model } = require('sequelize')
module.exports = (sequelize) => {
class Device extends Model { }
Device.init({
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true
},
identifier: DataTypes.STRING,
clientName: DataTypes.STRING, // e.g. Abs Web, Abs Android
clientVersion: DataTypes.STRING,
ipAddress: DataTypes.STRING,
deviceName: DataTypes.STRING, // e.g. Windows 10 Chrome, Google Pixel 6, Apple iPhone 10,3
deviceVersion: DataTypes.STRING // e.g. Browser version or Android SDK
}, {
sequelize,
2023-03-19 21:19:22 +01:00
modelName: 'device'
})
2023-03-19 21:19:22 +01:00
const { user } = sequelize.models
2023-03-19 21:19:22 +01:00
user.hasMany(Device)
Device.belongsTo(user)
return Device
}