feat(skydiver-profile): add SkydiverProfile MySQL model and service
Introduces the skydiver_profile table as an optional 1-to-1 extension of the user table, holding skydive-specific fields (licence, poids, bg_image). Wired up with Sequelize associations and a service with upsert support. Migration, model, relationships, and service layer all included.
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
exports.ArticleService = require('./mysql/article.service');
|
||||
exports.CommentService = require('./mysql/comment.service');
|
||||
exports.ProductService = require('./mysql/product.service');
|
||||
exports.SkydiverProfileService = require('./mysql/skydiver-profile.service');
|
||||
exports.TagService = require('./mysql/tag.service');
|
||||
exports.UserService = require('./mysql/user.service');
|
||||
//exports.HeroWarService = require('./mysql/herowars.service');
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
const DB = require('../../database/mysql');
|
||||
|
||||
const { SkydiverProfile } = DB;
|
||||
|
||||
class SkydiverProfileService {
|
||||
static async getByUserId(userId) {
|
||||
return SkydiverProfile.findByPk(userId);
|
||||
}
|
||||
|
||||
static async upsert(userId, data) {
|
||||
const [profile] = await SkydiverProfile.upsert({ userId, ...data });
|
||||
return profile;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = SkydiverProfileService;
|
||||
Reference in New Issue
Block a user