1
Good would like the help of you gentlemen, I have two tables customer and product a customer may have several products and one product belongs to only one customer, I have a relationship using sequel, but in the log I cannot display the result of the related table, which arrives to me this way
[ clientes {
dataValues: {
id: 1,
cliente: 'Mayk A Bublitiz',
email: '[email protected]',
celular: 'sdasds',
telefone: '984217583',
comments: [Array]
},
_previousDataValues: {
id: 1,
cliente: 'Mayk A Bublitiz',
email: '[email protected]',
celular: 'sdasds',
telefone: '984217583',
comments: [Array]
},
_changed: Set {},
_options: {
isNewRecord: false,
_schema: null,
_schemaDelimiter: '',
include: [Array],
includeNames: [Array],
includeMap: [Object],
includeValidated: true,
attributes: [Array],
raw: true
},
isNewRecord: false,
comments: [ [pedidos], [pedidos], [pedidos] ]},clientes {
dataValues: {
id: 2,
cliente: 'Maydasdask A Bublitiz',
email: '[email protected]',
celular: 'dasds',
telefone: '984217583',
comments: [Array]
},
_previousDataValues: {
id: 2,
cliente: 'Maydasdask A Bublitiz',
email: '[email protected]',
celular: 'dasds',
telefone: '984217583',
comments: [Array]
},
_changed: Set {},
_options: {
isNewRecord: false,
_schema: null,
_schemaDelimiter: '',
include: [Array],
includeNames: [Array],
includeMap: [Object],
includeValidated: true,
attributes: [Array],
raw: true
},
isNewRecord: false,
comments: [ [pedidos], [pedidos], [pedidos] ]},clientes {
dataValues: {
id: 3,
cliente: 'alone',
email: '[email protected]',
celular: 'adsd',
telefone: '984217583',
comments: [Array]
},
_previousDataValues: {
id: 3,
cliente: 'alone',
email: '[email protected]',
celular: 'adsd',
telefone: '984217583',
comments: [Array]
},
_changed: Set {},
_options: {
isNewRecord: false,
_schema: null,
_schemaDelimiter: '',
include: [Array],
includeNames: [Array],
includeMap: [Object],
includeValidated: true,
attributes: [Array],
raw: true
},
isNewRecord: false,
comments: [ [pedidos], [pedidos], [pedidos] ]}]
my relationship
db.Clientes.hasMany(db.Pedidos, { as: "comments" });db.Pedidos.belongsTo(db.Clientes, {foreignKey: "id_cliente",as: "tutorial",});
my code to display
app.post('/pdf',urlencodeParser,function (req,res) {
Cliente.findAll({ include: [{model:Pedido, as:"comments" }]}).then(function (pagamentos) {
console.log(typeof pagamentos);
res.render('pdf',{teste2:pagamentos,layout:false})
})})
I hope you gentlemen can help me give thanks