Hi,
I’ve created a data base view, called stats
, that exposes a number of fields. I’ve added this as a model:
module.exports = (sequelize, DataTypes) => {
const { Sequelize } = sequelize;
const PropertyStats = sequelize.define('property_stats', {
id: {
type: DataTypes.UUID,
primaryKey: true,
allowNull: false,
},
percentSharesSold: {
type: DataTypes.FLOAT,
},
totalPercentageRaised: {
type: DataTypes.FLOAT,
},
});
return PropertyStats;
};
When I try to view the table I get this error:
Unexpected error: column "createdAt" does not exist
I haven’t defined this field, it makes no sense on this view. Why is FA looking for it?
Also, is there any way that I can append the columns in this view onto the table view of another collection?
Update: I’ve tried adding paranoid: false
, it makes no difference:
const PropertyStats = sequelize.define('property_stats', {
id: {
type: DataTypes.UUID,
primaryKey: true,
allowNull: false,
},
percentSharesSold: {
type: DataTypes.FLOAT,
},
totalPercentageRaised: {
type: DataTypes.FLOAT,
},
}, {
paranoid: false
});
Hey @timothyarmes,
Sequelize handle createdAt
and updatedAt
by default, and so does FA. You can disable these column manually using something like
sequelize.define('user', { /* bla */ }, {
// don't add the timestamp attributes (updatedAt, createdAt)
timestamps: false,
// If don't want createdAt
createdAt: false,
// If don't want updatedAt
updatedAt: false,
// your other configuration here
});
(See node.js - disable updatedAt (update date) field in sequelize.js - Stack Overflow)
For your second question, I think Smart fields/Smart relationships is what you are looking for.
Let me know if that helps
1 Like
Hi,
Thank you, that worked for both questions.!
1 Like