I have:
db.Animal.findAll({ attributes: ['id', 'name'], include: [db.Age] }).success(function(results) {
console.log(JSON.stringify(results));
});
It gives me the fields ID and NAME from table Animal... but I also want to get specific fields from table Age and not all the fields (this is how it is working right now).
What can I do?
You can specify attributes within the include array. Try rearranging like so:
db.Animal.findAll({ attributes: ['id', 'name'],
include: [{ model: db.Age, attributes: ['field1'] }]
})
.success(function(res){ console.log( JSON.stringify(res) ) })
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With