Merge branch 'master' of wopr.rodax-software.com:lqdvi/app2-api
This commit is contained in:
commit
9492afe5ad
@ -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',
|
||||
|
||||
@ -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;
|
||||
};
|
||||
@ -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);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user