Sequelize, problem getting associations to return

后端 未结 4 1681
旧时难觅i
旧时难觅i 2021-02-15 13:20

I\'m currently experimenting with Sequelize and have two objects, a Person and Position, When getting a list of persons I want to get their position. <

4条回答
  •  攒了一身酷
    2021-02-15 13:41

    since I rewrote sequelize for 1.0 I removed the support of fetchAssociations. I will add it in the next weeks. But let's take a look at your code:

    You are using underscore-like column names, so you probably want to use the underscore option for automatically generated columns: http://www.sequelizejs.com/?active=usage#usage --> scroll a bit down or search for underscore. This might save you the options for belongsTo/hasMany.

    What you want to do with findAll is smth. like this:

    User.findAll().on('success', function(users) {
      // asd
    })
    

    And as I just noticed... it's somewhat tricky to get all associated objects :D So much for now. Hope that helped.

提交回复
热议问题