Comments (5)
Same issue here. I'm new to Node and Sequelize is the first ORM I'm choosing to test out but it's making it extremely difficult to get up and running with this error. (Using ExpressJS as well).
from express-example.
will check this!
from express-example.
Same here
Express
500 TypeError: e:\Aleem Practice\sequelize-expressjs-example-master\views\index.jade:24
22| input(type="text", name="title")
23| input(type="submit")
> 24| each task in user.tasks
25| li
26| = task.title
27| |
Cannot read property 'length' of undefined
22| input(type="text", name="title")
23| input(type="submit")
> 24| each task in user.tasks
25| li
26| = task.title
27| |
Cannot read property 'length' of undefined
at $l (eval at (e:\Aleem Practice\sequelize-expressjs-example-master\node_modules\jade\lib\jade.js:179:8), :129:31)
at eval (eval at (e:\Aleem Practice\sequelize-expressjs-example-master\node_modules\jade\lib\jade.js:179:8), :204:4)
at eval (eval at (e:\Aleem Practice\sequelize-expressjs-example-master\node_modules\jade\lib\jade.js:179:8), :344:4)
at eval (eval at (e:\Aleem Practice\sequelize-expressjs-example-master\node_modules\jade\lib\jade.js:179:8), :354:22)
at res (e:\Aleem Practice\sequelize-expressjs-example-master\node_modules\jade\lib\jade.js:180:38)
at Object.exports.render (e:\Aleem Practice\sequelize-expressjs-example-master\node_modules\jade\lib\jade.js:305:10)
at Object.exports.renderFile (e:\Aleem Practice\sequelize-expressjs-example-master\node_modules\jade\lib\jade.js:341:18)
at View.exports.renderFile [as engine] (e:\Aleem Practice\sequelize-expressjs-example-master\node_modules\jade\lib\jade.js:326:21)
at View.render (e:\Aleem Practice\sequelize-expressjs-example-master\node_modules\express\lib\view.js:76:8)
at Function.app.render (e:\Aleem Practice\sequelize-expressjs-example-master\node_modules\express\lib\application.js:504:10)
from express-example.
I just solved it!!!
1.In the file /models/users.js there's a line that starts with 'User.hasMany'. Change it so that it reads:
User.hasMany(models.Task, {as:'tasks'});
2.In the file /routes/index.js there's a line that starts with 'include'. Change it so that it reads:
include: [ {model: db.Task, as: 'tasks'} ]
Note: I'm using postgreSQL (the code is thought for mysql, however I'd bet this fact is not related with this issue)
from express-example.
The actual problem was that the code used user.tasks
whereas it has to be user.Tasks
. Though I wonder if that has always been the case.
from express-example.
Related Issues (20)
- I'm receiving a ERROR: sequelize is not defined HOT 2
- How to use the transaction? HOT 1
- Add TypeScript Example HOT 2
- Add examples of associations HOT 1
- nodemon index.js doesn't work
- upsert route HOT 1
- Should the directory structure be updated to adapt to the directory structure of Sequelize CLI?
- Contributing and Maintaining information HOT 2
- dynamic imports do not work for defining models HOT 2
- "node_modules/.bin/sequelize" is not work on windows HOT 2
- Unit test hanging or sequelize doesn't close connection HOT 1
- enable Travis CI / Circle CI
- Why we need to define structure of database TWICE? HOT 8
- how to use DataType from req.body HOT 2
- npm install error HOT 4
- duplicate foreignKey when using sequelize.sync() HOT 3
- What does Model.associate() do in model/index.js ? HOT 4
- Please provide an example using sequelize v5 and TypeScript. HOT 6
- Update this repo HOT 3
- Stop using `sequelize.import` HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from express-example.