I have a database already built and I am using it with Sequelize ORM. The database already has timestamp columns as "created_at" and "updated_at".
To generate sequelize Models I used sequelize-auto and it generated all the models with one command. But when I use any model to fetch data. It returns error "unknown column createdAt".
Therefore I manually opened a model file and edited it with "underscored: true" and it solved the problem. But I want this option to be set globally for all models. Therefore after googling for some time I came to know about -c option with "sequelize-auto" command.
So I created a json file and passed the path to this file in -c option. But again all the models were without "underscored: true" option.
I used this option as follows
sequelize-auto -o "./models" -d sequelize_auto_test -h localhost -u my_username -x my_password -e mysql -c ./config/config.json
I also used this command with quotes
sequelize-auto -o "./models" -d sequelize_auto_test -h localhost -u my_username -x my_password -e mysql -c "./config/config.json"
You have to write down your ./config/config.json just simple:
On my case, i'm already have the created_at and updated_at, so lets the sequelize not retrieve automatically and including schema, i have to set on my config :
then, execute again sequelize-auto.
All models will auto include that options.
-ManzTIHAGI