Añadir Time Zone a los Venues
This commit is contained in:
parent
3f0b87870c
commit
444d364f1a
@ -1,68 +1,75 @@
|
|||||||
'use strict';
|
"use strict";
|
||||||
|
|
||||||
const cdnHelper = require('../../helpers/cdn.helper');
|
const cdnHelper = require("../../helpers/cdn.helper");
|
||||||
|
|
||||||
module.exports = function (sequelize, DataTypes) {
|
module.exports = function (sequelize, DataTypes) {
|
||||||
const Venue = sequelize.define('Venue', {
|
const Venue = sequelize.define(
|
||||||
id: {
|
"Venue",
|
||||||
type: DataTypes.UUID,
|
{
|
||||||
defaultValue: DataTypes.UUIDV4,
|
id: {
|
||||||
primaryKey: true,
|
type: DataTypes.UUID,
|
||||||
|
defaultValue: DataTypes.UUIDV4,
|
||||||
|
primaryKey: true,
|
||||||
|
},
|
||||||
|
name: {
|
||||||
|
type: DataTypes.STRING,
|
||||||
|
allowNull: false,
|
||||||
|
},
|
||||||
|
description: {
|
||||||
|
type: DataTypes.STRING,
|
||||||
|
},
|
||||||
|
address: {
|
||||||
|
type: DataTypes.STRING,
|
||||||
|
allowNull: false,
|
||||||
|
},
|
||||||
|
city: {
|
||||||
|
type: DataTypes.STRING,
|
||||||
|
allowNull: false,
|
||||||
|
},
|
||||||
|
country: {
|
||||||
|
type: DataTypes.STRING,
|
||||||
|
},
|
||||||
|
state: {
|
||||||
|
type: DataTypes.STRING,
|
||||||
|
},
|
||||||
|
postal_code: {
|
||||||
|
type: DataTypes.STRING,
|
||||||
|
},
|
||||||
|
accessibility: {
|
||||||
|
type: DataTypes.STRING,
|
||||||
|
},
|
||||||
|
gmt: {
|
||||||
|
type: DataTypes.INTEGER,
|
||||||
|
allowNull: false,
|
||||||
|
defaultValue: 1,
|
||||||
|
},
|
||||||
|
latitude: {
|
||||||
|
type: DataTypes.DECIMAL(10, 8),
|
||||||
|
},
|
||||||
|
longitude: {
|
||||||
|
type: DataTypes.DECIMAL(11, 8),
|
||||||
|
},
|
||||||
|
image_url: {
|
||||||
|
type: DataTypes.VIRTUAL,
|
||||||
|
get: function () {
|
||||||
|
const city = this.get("city");
|
||||||
|
return cdnHelper.getCDNCityMediaUrl(city);
|
||||||
},
|
},
|
||||||
name: {
|
},
|
||||||
type: DataTypes.STRING,
|
tz: {
|
||||||
allowNull: false,
|
type: DataTypes.STRING,
|
||||||
},
|
},
|
||||||
description: {
|
},
|
||||||
type: DataTypes.STRING,
|
{
|
||||||
},
|
tableName: "venues",
|
||||||
address: {
|
freezeTableName: true,
|
||||||
type: DataTypes.STRING,
|
timestamps: true,
|
||||||
allowNull: false,
|
}
|
||||||
},
|
);
|
||||||
city: {
|
|
||||||
type: DataTypes.STRING,
|
|
||||||
allowNull: false,
|
|
||||||
},
|
|
||||||
country: {
|
|
||||||
type: DataTypes.STRING,
|
|
||||||
},
|
|
||||||
state: {
|
|
||||||
type: DataTypes.STRING,
|
|
||||||
},
|
|
||||||
postal_code: {
|
|
||||||
type: DataTypes.STRING,
|
|
||||||
},
|
|
||||||
accessibility: {
|
|
||||||
type: DataTypes.STRING,
|
|
||||||
},
|
|
||||||
gmt: {
|
|
||||||
type: DataTypes.INTEGER,
|
|
||||||
allowNull: false,
|
|
||||||
defaultValue: 1,
|
|
||||||
},
|
|
||||||
latitude: {
|
|
||||||
type: DataTypes.DECIMAL(10, 8),
|
|
||||||
},
|
|
||||||
longitude: {
|
|
||||||
type: DataTypes.DECIMAL(11, 8),
|
|
||||||
},
|
|
||||||
image_url: {
|
|
||||||
type: DataTypes.VIRTUAL,
|
|
||||||
get: function () {
|
|
||||||
const city = this.get('city');
|
|
||||||
return cdnHelper.getCDNCityMediaUrl(city)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
tableName: 'venues',
|
|
||||||
freezeTableName: true,
|
|
||||||
timestamps: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
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" });
|
||||||
};
|
};
|
||||||
|
|
||||||
return Venue;
|
return Venue;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,15 +1,16 @@
|
|||||||
const Joi = require('joi');
|
const Joi = require("joi");
|
||||||
|
|
||||||
const VenueInputType = Joi.object().keys({
|
const VenueInputType = Joi.object().keys({
|
||||||
name: Joi.string().required(),
|
name: Joi.string().required(),
|
||||||
address: Joi.string().required(),
|
address: Joi.string().required(),
|
||||||
city: Joi.string().required(),
|
city: Joi.string().required(),
|
||||||
gmt: Joi.number().min(-12).max(+12),
|
gmt: Joi.number().min(-12).max(+12),
|
||||||
description: Joi.string().optional(),
|
description: Joi.string().optional(),
|
||||||
country: Joi.string().optional(),
|
country: Joi.string().optional(),
|
||||||
state: Joi.string().optional(),
|
state: Joi.string().optional(),
|
||||||
postal_code: Joi.string().optional(),
|
postal_code: Joi.string().optional(),
|
||||||
accessibility: Joi.string().optional()
|
accessibility: Joi.string().optional(),
|
||||||
|
tz: Joi.string().optional(),
|
||||||
});
|
});
|
||||||
/*
|
/*
|
||||||
const VenueOutputType = Joi.object().keys({
|
const VenueOutputType = Joi.object().keys({
|
||||||
@ -19,6 +20,6 @@ const VenueOutputType = Joi.object().keys({
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
VenueInputType,
|
VenueInputType,
|
||||||
// VenueOutputType
|
// VenueOutputType
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user