a
This commit is contained in:
parent
0132047367
commit
cd5d39bc97
@ -13,10 +13,6 @@ module.exports = function (sequelize, DataTypes) {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
},
|
||||
type: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
},
|
||||
content: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false
|
||||
|
||||
@ -84,17 +84,18 @@ module.exports = function (sequelize, DataTypes) {
|
||||
Speaker.EventDetails = Speaker.hasMany(models.EventDetail, { foreignKey: 'speakerId', as: "eventdetails" });
|
||||
Speaker.Questions = Speaker.hasMany(models.EventQuestion, { foreignKey: 'speakerId', as: "questions" });
|
||||
|
||||
//OJOJOJOJOJOJOJJOJ
|
||||
// OJO GENERA UN FOREIGN KEY Con eventos y habrá ID de otras entidades que no exitan en la tabla eventos, porque son post o speakers
|
||||
Speaker.Multimedias = Speaker.hasMany(models.Multimedia, {
|
||||
foreignKey: 'entityId',
|
||||
as: { singular: 'multimedia', plural: 'multimedias' }
|
||||
});
|
||||
|
||||
/*
|
||||
Speaker.Multimedias = Speaker.belongsToMany(models.MultimediaFile, {
|
||||
through: models.MultimediaSpeaker,
|
||||
foreignKey: 'speakerId'
|
||||
Speaker.Comments = Speaker.hasMany(models.Comment, {
|
||||
foreignKey: 'entityId',
|
||||
as: { singular: 'comment', plural: 'comments' }
|
||||
});
|
||||
*/
|
||||
|
||||
};
|
||||
|
||||
Speaker.addScope('featured', {
|
||||
@ -134,5 +135,16 @@ module.exports = function (sequelize, DataTypes) {
|
||||
}
|
||||
});
|
||||
|
||||
Speaker.addScope('includeComments', () => {
|
||||
return {
|
||||
include: [{
|
||||
model: sequelize.models.Comment,
|
||||
as: 'comments',
|
||||
required: false,
|
||||
}]
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return Speaker;
|
||||
};
|
||||
@ -60,7 +60,7 @@ routes.get('/speakers/:id',
|
||||
invalidFields: generalInvalidFields
|
||||
}),
|
||||
speakerController.findOne({
|
||||
scopes: ['defaultScope', 'includeValues', 'includeMultimedias'],
|
||||
scopes: ['defaultScope', 'includeValues', 'includeMultimedias', 'includeComments'],
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
37
script-carga-bd-COMENTARIOS.sql
Normal file
37
script-carga-bd-COMENTARIOS.sql
Normal file
File diff suppressed because one or more lines are too long
@ -151,7 +151,11 @@ SELECT UUID() as ID, conferenceId, speakerId, anonymous, answered, discared, con
|
||||
|
||||
|
||||
|
||||
|
||||
//COMENTARIOS.....
|
||||
insert into lqdvi_v2.comments (id, entityId, entityname, content, createdAt, updatedAt, userId)
|
||||
|
||||
SELECT UUID() as ID, speakerid, 'speaker', content, created, created, '0939bb2a-d33d-4290-ac81-fc9faa1c015e'
|
||||
FROM lqdvi.`speaker-comment`;
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user