3

"I want to get some attributes of an include table instead of using *, my code right now is this.

module.exports = function(app){
    app.get('/post', function(req, res){
        model.Post.findAll(
            { attributes: ["body", "id"],
            {include: [model.User]).success(function(rows){
                    res.json(rows);
            }

        );


    });

This works fine , but the query gets some data that i really don't need( password, birth, email) How can i get only , for example the username and avatar of the inlclude table User?

Jose Sosa
  • 2,157
  • 3
  • 17
  • 18

1 Answers1

1

You should be able to specify what you want back via the attributes property. I'm not sure what your schema looks like, so I may need to look a little different, but here's my best guess:

// If password, birth, and email are nested in the body:
{ attributes: ["body.username", "body.avatar", "id"],
...

That should work. If not, please post your schema.

EmptyArsenal
  • 7,314
  • 4
  • 33
  • 56