module.exports = (sequelize, DataTypes) => {
	let Settings = sequelize.define('Settings', {
		siteName: {
			type: DataTypes.STRING,
			validate: {
				isString (val) {
					if(typeof val !== 'string') {
						throw new sequelize.ValidationError('The name must be a string')
					}
				}
			}
		},
		siteDesc: {
			type: DataTypes.STRING,
			validate: {
				isString (val) {
					if(typeof val !== 'string') {
						throw new sequelize.ValidationError('The description must be a string')
					}
				}
			}
		},
		bannerText: {
			type: DataTypes.STRING,
			validate: {
				isString (val) {
					if(typeof val !== 'string') {
						throw new sequelize.ValidationError('The banner text must be a string')
					}
				}
			}
		},
		bannerEnabled: {
			type: DataTypes.BOOLEAN,
			defaultValue: false
		},
		maintenance: {
			type: DataTypes.BOOLEAN,
			defaultValue: false
		},
		gateway: {
			type: DataTypes.STRING,
			defaultValue: "wss://gateway.kaverti.com"
		},
		RegistrationsDisabled: {
			type: DataTypes.BOOLEAN,
			defaultValue: false
		},
	}, {
		classMethods: {
			set (values) {
				values.id = 1
				return Settings.upsert(values)
			},
			get () {
				return Settings.findById(1)
			}
		}
	})

	return Settings
}
