Merge branch 'master' of wopr.rodax-software.com:lqdvi/app2-api

This commit is contained in:
David Arranz 2019-07-17 14:45:57 +02:00
commit 9492afe5ad
3 changed files with 8 additions and 8 deletions

View File

@ -15,7 +15,7 @@ const globOptions = {
module.exports = function () {
const router = express.Router({ mergeParams: true });
router.get('/_health', (req, res, next) => {
router.get('/v2/_health', (req, res, next) => {
res.json({
code: 200,
message: 'success',

View File

@ -23,10 +23,11 @@ module.exports = function (sequelize, DataTypes) {
Entity.associate = function (models) {
Entity.EntityTypes = Entity.belongsToMany(models.EntityType, {
through: models.EntityEntitiesTypes,
foreignKey: 'entityId'
foreignKey: 'entityId',
as: 'types'
});
Entity.User = Entity.hasMany(models.User, { foreignKey: 'entityId' });
Entity.EventsReservations = Entity.hasMany(models.EventReservation, { foreignKey: 'entityId' });
Entity.EventsReservations = Entity.hasMany(models.EventReservation, { foreignKey: 'entityId', as: 'reservations' });
};
return Entity;
};

View File

@ -12,13 +12,12 @@ const extraMethods = {
const findOptions = parseParamsToFindOptions(params);
findOptions.include.push({
model: models.EntityType, where: { alias: type }, attributes: [],
model: models.EntityType,
as: 'types',
where: { alias: type },
attributes: [],
});
findOptions.where = Object.assign({},
findOptions.where, {
state: 'publish'
});
try {
return await models.Entity.findAll(findOptions);