DB: Add models and migration for badges

This commit is contained in:
2023-02-27 01:56:44 +01:00
parent 1a5e7c1b62
commit 06575d280f
4 changed files with 69 additions and 0 deletions

View File

@@ -17,6 +17,8 @@ module.exports = (sequelize, DataTypes) => {
User.hasMany(models.Card);
User.hasMany(models.CurrencyHistory);
User.hasOne(models.Profile);
// A user can have many badges
User.belongsToMany(models.Badge, { through: 'BadgeUser' });
}
async addExperience(amount, source='unknown') {
console.log(`Adding ${amount} experience to user ${this.id}`);