a
This commit is contained in:
parent
0132047367
commit
cd5d39bc97
@ -13,10 +13,6 @@ module.exports = function (sequelize, DataTypes) {
|
|||||||
type: DataTypes.STRING,
|
type: DataTypes.STRING,
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
},
|
},
|
||||||
type: {
|
|
||||||
type: DataTypes.STRING,
|
|
||||||
allowNull: false,
|
|
||||||
},
|
|
||||||
content: {
|
content: {
|
||||||
type: DataTypes.STRING,
|
type: DataTypes.STRING,
|
||||||
allowNull: false
|
allowNull: false
|
||||||
|
|||||||
@ -84,17 +84,18 @@ module.exports = function (sequelize, DataTypes) {
|
|||||||
Speaker.EventDetails = Speaker.hasMany(models.EventDetail, { foreignKey: 'speakerId', as: "eventdetails" });
|
Speaker.EventDetails = Speaker.hasMany(models.EventDetail, { foreignKey: 'speakerId', as: "eventdetails" });
|
||||||
Speaker.Questions = Speaker.hasMany(models.EventQuestion, { foreignKey: 'speakerId', as: "questions" });
|
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, {
|
Speaker.Multimedias = Speaker.hasMany(models.Multimedia, {
|
||||||
foreignKey: 'entityId',
|
foreignKey: 'entityId',
|
||||||
as: { singular: 'multimedia', plural: 'multimedias' }
|
as: { singular: 'multimedia', plural: 'multimedias' }
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
Speaker.Comments = Speaker.hasMany(models.Comment, {
|
||||||
Speaker.Multimedias = Speaker.belongsToMany(models.MultimediaFile, {
|
foreignKey: 'entityId',
|
||||||
through: models.MultimediaSpeaker,
|
as: { singular: 'comment', plural: 'comments' }
|
||||||
foreignKey: 'speakerId'
|
|
||||||
});
|
});
|
||||||
*/
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Speaker.addScope('featured', {
|
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;
|
return Speaker;
|
||||||
};
|
};
|
||||||
@ -60,7 +60,7 @@ routes.get('/speakers/:id',
|
|||||||
invalidFields: generalInvalidFields
|
invalidFields: generalInvalidFields
|
||||||
}),
|
}),
|
||||||
speakerController.findOne({
|
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