You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes we encounter a hardly spotted bug in the mappings when we rely on some relation being loaded that is actually not loaded.
// invalid case
const video = await store.get(Video, { where: { id: SomeId } })
console.log(video.channel) // undefined;
// valid case
const video = await store.get(Video, { where: { id: SomeId }, relations: ['channel'] })
console.log(video.channel)
As shown in the example, if a developer forgets to add relations: ['myEntity'] and then tries to access it, the error occurs. Currently, this is not caught by a compiler.
Let's try to improve our Typescript type guards for DatabaseManager so that .get and other methods return type that signals what relations are actually loaded and triggers compilation errors when not-loaded relations are used.
The text was updated successfully, but these errors were encountered:
Sometimes we encounter a hardly spotted bug in the mappings when we rely on some relation being loaded that is actually not loaded.
As shown in the example, if a developer forgets to add
relations: ['myEntity']
and then tries to access it, the error occurs. Currently, this is not caught by a compiler.Let's try to improve our Typescript type guards for
DatabaseManager
so that.get
and other methods return type that signals what relations are actually loaded and triggers compilation errors when not-loaded relations are used.The text was updated successfully, but these errors were encountered: