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.

Vanilla JavaScript Lazy Loading Relations

See original GitHub issue

Issue type:

[ ] question [ x ] bug report [ ] feature request [ ] documentation issue

Database system/driver:

[ ] cordova [ ] mongodb [ ] mssql [ ] mysql / mariadb [ ] oracle [ x ] postgres [ ] sqlite [ ] sqljs [ ] react-native

TypeORM version:

[ x ] latest [ ] @next [ ] 0.x.x (or put your version here)

Steps to reproduce or a small repository showing the problem:

I am using TypeORM with vanilla JavaScript and I have a one-to-many relation on a model (let’s call it model1) and its inverse many-to-one relation on another model (let’s call it model2). I have set up the Model2Schema to the default eager load and Model1Schema to lazy load the relation (since I don’t want to always load the “many” part each time I get this model). However I always get the model1.model2s to be empty. My code looks like this: Model1.findOne({}).then(async model1 => { console.log(model1); let model2s = await model1.model2s; console.log(model2s); }).catch(error); The model2s variable is undefined. P.S. I had to define the then callback as async since await has to work with async functions.

Any help?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
pleerockcommented, Jun 25, 2018

We are planning to add JavaScript docs in next 0.3.0 version.

3reactions
ahmedosama94commented, Jun 24, 2018

The problem was that I did not specify the inverseSide of the relation. I came to that conclusion with a lot of tinkering and looking through a lot of the typeorm code though. It would be really helpful if there is a bit more documentation for Vanilla Javascript. 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

Lazy loading images with vanilla JavaScript
The Intersection Observer API watches the lazy-loaded images. When user scrolls/tabs toward each image, it requests the actual image and swaps ...
Read more >
Lazy Loading Images with Vanilla JavaScript
Lazy loading is a technique that helps to improve the page load time and reduces page size. We can use this technique with...
Read more >
Browser-level image lazy loading for the web - web.dev
Relationship between the loading attribute and fetch priority # ... The eager value is simply an instruction to load the image as usual,...
Read more >
Lazy Loading JavaScript Modules With ConditionerJS
Linking JavaScript functionality to the DOM can be a repetitive and tedious task. In this article, Rik Schennink explains how ConditionerJS ...
Read more >
Lazy Loading Video - ottball
You can make your JavaScript files load asynchronously by using the async attribute. ... When you mark a script as async , your...
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