question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

What is the intended behavior of the include option when using model.build?

See original GitHub issue

The documentation does not clearly explain what is supposed to happen when you perform:

myModel = await MyModel.build(data, { include: [MyOtherModel] });

My expectation was that the myOtherModel property would be populated at the time of calling build() (since the myOtherModelId foreign key is definitely in the database), but from looking at the object in the debugger, this does not appear to be the case.

My desire is to be able to build an object then be able to get the value of myModel.myOtherModel.id, but since myOtherModel is undefined, this doesn’t work.

Is there any way to get myOtherModel to populate without having to save the model? (I do not want to save the model unless a particular condition is met.)

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
devuxercommented, Jul 23, 2019

As far as I know this is still an issue.

Bump

1reaction
SimonSchickcommented, Apr 21, 2019

Yea… I didn’t know that either 😛

Read more comments on GitHub >

github_iconTop Results From Across the Web

Behavioral Change Models - SPH
The TPB states that behavioral achievement depends on both motivation (intention) and ability (behavioral control). It distinguishes between three types of ...
Read more >
PBS Practice Competing Behavior Model
The competing behavior model helps to provide a link between functional assessment informa- tion and developing a positive behavioral support plan.
Read more >
Behavior Management Models
This chapter describes what is meant by disci- pline and various models used in schools to deal with student behavior. An analysis of...
Read more >
The behaviour change wheel: A new method for ...
It includes habitual processes, emotional responding, as well as analytical decision-making.
Read more >
Encouraging Appropriate Behavior - IRIS Center
Choice Making . ... InTASC Model Core Teaching Standards are designed to help teachers of all ... behavior through the use of evidence-based...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found