I am using sequelize ORM; everything is great and clean, but I had a problem when I use it with join queries.
I have two models: users and posts.
var User = db.seq.define('User',{
    username: { type: db.Sequelize.STRING},
    email: { type: db.Sequelize.STRING},
    password: { type: db.Sequelize.STRING},
    sex : { type: db.Sequelize.INTEGER},
    day_birth: { type: db.Sequelize.INTEGER},
    month_birth: { type: db.Sequelize.INTEGER},
    year_birth: { type: db.Sequelize.INTEGER}
});
User.sync().success(function(){
    console.log("table created")
}).error(function(error){
    console.log(err);
})
var Post = db.seq.define("Post",{
    body: { type: db.Sequelize.TEXT },
    user_id: { type: db.Sequelize.INTEGER},
    likes: { type: db.Sequelize.INTEGER, defaultValue: 0 },
});
Post.sync().success(function(){
    console.log("table created")
}).error(function(error){
    console.log(err);
})
I want a query that respond with a post with the info of user that made it. In the raw query, I get this:
db.seq.query('SELECT * FROM posts, users WHERE posts.user_id = users.id ').success(function(rows){
            res.json(rows);
        });
My question is how can I change the code to use the ORM style instead of the SQL query?
 
     
     
     
     
     
     
     
    