Answer the question
In order to leave comments, you need to log in
Sequelize, PUG and length?
In general, my roof is already starting to boil from this ...
There is a database, it seems like there are three photos in it.
We have a model (I specifically insert all the code from the file, because it is the most suspect):
// /models/photo.js
const Sequelize = require('sequelize');
const db = require('../config/database');
const Photo = db.define('photo', {
photo_id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
alt: {
type: Sequelize.STRING
},
description: {
type: Sequelize.STRING
},
image: {
type: Sequelize.STRING
},
},{
timestamps: false,
freezeTableName: true,
});
module.exports = Photo;
router.get('/photo', (req, res) => {
Photo.findAll()
.then(photos => {
console.log(photos.length); // выводит 3!
res.render('index', {
photos: photos
});
})
.catch((err) => console.log(`Error: ${err}`));
});
each key in photos
p= key.image
| #{photos}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question