a
This commit is contained in:
parent
948bd01edc
commit
ae2589c04f
@ -25,7 +25,7 @@ const extraControllers = {
|
|||||||
const eventId = params.params.id;
|
const eventId = params.params.id;
|
||||||
const encodedInvitationCode = params.params.encodedInvitationCode;
|
const encodedInvitationCode = params.params.encodedInvitationCode;
|
||||||
|
|
||||||
const registrationCode = encodedInvitationCode; //Buffer.from(req.params.encodedInvitationCode, 'base64').toString('ascii');
|
const registrationCode = Buffer.from(req.params.encodedInvitationCode, 'base64').toString('ascii');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await eventReservationService._getReservaByCode(eventId, registrationCode);
|
const result = await eventReservationService._getReservaByCode(eventId, registrationCode);
|
||||||
|
|||||||
@ -60,6 +60,19 @@ module.exports = function (sequelize, DataTypes) {
|
|||||||
timestamps: true,
|
timestamps: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Venue.addScope('includeCountEvents', () => {
|
||||||
|
return {
|
||||||
|
include: [
|
||||||
|
{ model: sequelize.models.Event,
|
||||||
|
as: 'events',
|
||||||
|
attributes:[[sequelize.fn('COUNT', sequelize.col('id')), 'num_editions']],
|
||||||
|
required: false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
Venue.associate = function (models) {
|
Venue.associate = function (models) {
|
||||||
Venue.Events = Venue.hasMany(models.Event, { foreignKey: 'venueId', as: 'events' });
|
Venue.Events = Venue.hasMany(models.Event, { foreignKey: 'venueId', as: 'events' });
|
||||||
};
|
};
|
||||||
@ -12,7 +12,9 @@ const venueController = require('./venue.controller');
|
|||||||
|
|
||||||
routes.get('/venues',
|
routes.get('/venues',
|
||||||
//SortMiddleware.middleware({ default: "name" }),
|
//SortMiddleware.middleware({ default: "name" }),
|
||||||
venueController.find({})
|
venueController.find({
|
||||||
|
scopes: ['includeCountEvents']
|
||||||
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
routes.get('/venues',
|
routes.get('/venues',
|
||||||
Loading…
Reference in New Issue
Block a user