.
This commit is contained in:
parent
421827450c
commit
c22bf72939
@ -15,7 +15,7 @@ const globOptions = {
|
|||||||
module.exports = function () {
|
module.exports = function () {
|
||||||
const router = express.Router({ mergeParams: true });
|
const router = express.Router({ mergeParams: true });
|
||||||
|
|
||||||
router.get('/_health', (req, res, next) => {
|
router.get('/v2/_health', (req, res, next) => {
|
||||||
res.json({
|
res.json({
|
||||||
code: 200,
|
code: 200,
|
||||||
message: 'success',
|
message: 'success',
|
||||||
|
|||||||
@ -23,10 +23,11 @@ module.exports = function (sequelize, DataTypes) {
|
|||||||
Entity.associate = function (models) {
|
Entity.associate = function (models) {
|
||||||
Entity.EntityTypes = Entity.belongsToMany(models.EntityType, {
|
Entity.EntityTypes = Entity.belongsToMany(models.EntityType, {
|
||||||
through: models.EntityEntitiesTypes,
|
through: models.EntityEntitiesTypes,
|
||||||
foreignKey: 'entityId'
|
foreignKey: 'entityId',
|
||||||
|
as: 'types'
|
||||||
});
|
});
|
||||||
Entity.User = Entity.hasMany(models.User, { foreignKey: 'entityId' });
|
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;
|
return Entity;
|
||||||
};
|
};
|
||||||
@ -12,13 +12,12 @@ const extraMethods = {
|
|||||||
const findOptions = parseParamsToFindOptions(params);
|
const findOptions = parseParamsToFindOptions(params);
|
||||||
|
|
||||||
findOptions.include.push({
|
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 {
|
try {
|
||||||
return await models.Entity.findAll(findOptions);
|
return await models.Entity.findAll(findOptions);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user