IssueRaiser

Eager loading associations when calling create() or save()

Let's say I have a Customer model that belongs to a User. I saw this on the documentation for create method: ``` [options.include] Array an array of include options - Used to build prefetched/included model instances ``` Source - http://docs.sequelizejs.com/en/latest/api/model/#createvalues-options-promiseinstance But when I tried it, its not eager loading the associated User. ``` Comment.create({ body: inputs.body, UserId: inputs.userId, }, { include: [User] }).then(function(comment) { // comment.User is undefined }); ``` is this a bug? Or I misunderstood the use of `options.include` for the create method?

Posted by johnnncodes on May 27, 2015, 5:35 AM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.7,000 issues0 comments

github (Other)

Eager loading associations when calling create() or save()

johnnncodesMay 27, 2015, 5:35 AM

Let's say I have a Customer model that belongs to a User. I saw this on the documentation for create method: ``` [options.include] Array an array of include options - Used to build prefetched/included model instances ``` Source - http://docs.sequelizejs.com/en/latest/api/model/#createvalues-options-promiseinstance But when I tried it, its not eager loading the associated User. ``` Comment.create({ body: inputs.body, UserId: inputs.userId, }, { include: [User] }).then(function(comment) { // comment.User is undefined }); ``` is this a bug? Or I misunderstood the use of `options.include` for the create method?

Comments (0)

No comments yet. Start the discussion.

Comment on this issue