let createDOMPurify = require('dompurify');
let { JSDOM } = require('jsdom');

let window = new JSDOM('').window;
let DOMPurify = createDOMPurify(window);
var escaped_str = require('querystring')
const Errors = require('../lib/errors')
let pagination = require('../lib/pagination.js')


module.exports = (sequelize, DataTypes) => {
    let TeamMembers = sequelize.define('TeamMembers', {
        teamId: {
            type: DataTypes.BIGINT,
            defaultValue: 1
        },
        userId: DataTypes.BIGINT,
        roles: {
            type: DataTypes.JSON,
            defaultValue: "1"
        },
    })
    TeamMembers.associate = function (models) {
        TeamMembers.belongsTo(models.User)
    }
    TeamMembers.includeOptions = function () {
        let models = sequelize.models

        return [
            { model: models.User, as: 'user', attributes: ['username', 'createdAt', 'id', 'color', 'picture']},
        ]
    }
    TeamMembers.prototype.leaveTeam = function () {
        this.destroy()
    }

    return TeamMembers
}
