safe-typeorm icon indicating copy to clipboard operation
safe-typeorm copied to clipboard

Implement `bindAppJoin()` who supports the lazy app join

Open samchon opened this issue 2 years ago • 0 comments

const group: BbsGroup = await BbsGroup.findOneOrFail();
safe.bindAppJoin(group);

const articleList: BbsArticle[] = await bbs.articles.get();
const top: BbsArticle = articleList[0];
await top.tags.get();
await top.comments.get();
await (await top.contents.get())[0].files.get();

// ANY SELECT QUERY WOULD BE OCCURED
// BECAUSE ALL OF THEM ALREADY BEEN LOADED BY
// LAZY APP JOIN
for (const article of articleList)
{
    await article.tags.get();
    await article.comments.get();
    for (const content of article.contents.get())
        await content.files.get();
}

samchon avatar Feb 01 '22 04:02 samchon