audiobookshelf/server/models/Device.js
2023-03-19 15:19:22 -05:00

29 lines
733 B
JavaScript

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,
modelName: 'device'
})
const { user } = sequelize.models
user.hasMany(Device)
Device.belongsTo(user)
return Device
}