From e6784eb666d33cfb092f210f3daf047c9eec7f66 Mon Sep 17 00:00:00 2001 From: Luiz Picolo Date: Thu, 28 Nov 2024 21:47:37 -0400 Subject: [PATCH] update --- config/config.json | 12 +++---- controllers/produtosController.js | 5 +-- database/development.sqlite | Bin 0 -> 20480 bytes migrations/20241129012306-create-produto.js | 36 +++++++++++++++++++ models/produto.js | 38 ++++++++++++-------- 5 files changed, 69 insertions(+), 22 deletions(-) create mode 100644 database/development.sqlite create mode 100644 migrations/20241129012306-create-produto.js diff --git a/config/config.json b/config/config.json index 29a2212..f80dece 100644 --- a/config/config.json +++ b/config/config.json @@ -1,14 +1,14 @@ { "development": { - "" - "dialect": "mysql" + "storage": "./database/development.sqlite", + "dialect": "sqlite" }, "test": { - - "dialect": "mysql" + "storage": "./database/test.sqlite", + "dialect": "sqlite" }, "production": { - - "dialect": "mysql" + "storage": "./database/production.sqlite", + "dialect": "sqlite" } } diff --git a/controllers/produtosController.js b/controllers/produtosController.js index c0347f5..d937769 100644 --- a/controllers/produtosController.js +++ b/controllers/produtosController.js @@ -1,5 +1,6 @@ -const Produto = require('../models/produto'); -const produtos = new Produto(); +//const Produto = require('../models/produto'); +//const produtos = new Produto(); +const { produto } = require('../models'); const listar = function(req, res){ res.render('produtos/listar', { diff --git a/database/development.sqlite b/database/development.sqlite new file mode 100644 index 0000000000000000000000000000000000000000..e21374607f227d29a2b54a7e2d3bc20f0f25634c GIT binary patch literal 20480 zcmeI&&u-H&90zc_?KYTH%B`nK);P4${;171q~7p47b23hOB1A?n$VajsA;-1l@K@J zO?VI9ggdXm5vR0b8A3=%95#KeTJbNj-T32Nerbo7W|T?xCQ0KUV<+S>p_Dvhj1W>* zbxYMvDXB(f6R0D-(f(7jOpepf)!KJbseU81UhT`Hj%uJl00Izz00bZa0SG_<0uX?} z{}LEfw(AE6bd&|Jr*d&URXN{yA+MKmHn|;cbsfQ7!CZcB3U;e+a~8z%P>s|+?v{7z zdwcZL)oRXpnuNf}6?lf-8|v(NKBQ5;;!__tn@R0f$0dFHbVwHDW~1he}t zvpv&f7ox{K(`8-Hanv`B^Q%LbTLU%UavuJ}Ky68P>Wv2dpsg&1IqWogFD;n`g`iYa zDO}5Ga^2!$e%-cb8<(EADW-Kw+jXl!Ni+-PyY)^5Y8O`VxG?*;T?q5s{z3k*RaK?6 zuS9)NAOHafKmY;|fB*y_009U<00I!Wg97`sWa%yawB6P_t+syBdV2Kp#mLe6b { + class produto extends Model { + /** + * Helper method for defining associations. + * This method is not a part of Sequelize lifecycle. + * The `models/index` file will call this method automatically. + */ + static associate(models) { + // define association here + } } - - buscarPorID(id){ - return this.listar().find(produto => produto.id == id) - } -} - -module.exports = Produto \ No newline at end of file + produto.init({ + nome: DataTypes.STRING, + preco: DataTypes.FLOAT, + imagem: DataTypes.STRING + }, { + sequelize, + modelName: 'produto', + }); + return produto; +}; \ No newline at end of file