Hi,
I want to check if a field exists in a given table, and if it do, get its type.
Example:
var foo = sequelize.define("Foo", {
bar: {
type: DataTypes.INTEGER,
}
});
console.log(foo.getAttribute('bar'));
/* Output:
{
type: DataTypes.INTEGER,
}
*/
console.log(foo.getAttribute('baz'));
/* Output: undefined */
Model.rawAttributes.key
It is returning me undefined.
Sequelize 3.13.0.
var Sequelize = require('sequelize');
var sequelize = new Sequelize('postgres', 'postgres', 'password',
{
"dialect" : "postgres",
"timezone" : "-03:00"
});
var foo = sequelize.define("Foo", {
bar: {
type: Sequelize.INTEGER,
}
});
sequelize
.sync()
.then(function() {
console.log(foo.rawAttribute);
/* Output: undefined */
});
Sorry it's rawAttributes, typo on my part.
Most helpful comment
Model.rawAttributes.key