You can query related models in three ways: - Option 1: use the `toArray()` function to lazy load related comments ```ts const post = await DataStore.query(Post, "YOUR_POST_ID") if (post) { const comments = await post.comments.toArray() } ``` ```js const post = await DataStore.query(Post, "YOUR_POST_ID"); const comments = await post.comments.toArray(); ``` - Option 2: use async iterators to lazy load related comments ```ts const post = await DataStore.query(Post, "YOUR_POST_ID"); if (post) { for await (const comment of post.comments) { console.log(comment) }; } ``` ```js const post = await DataStore.query(Post, "YOUR_POST_ID"); for await (const comment of post.comments) { console.log(comment) }; ``` - Option 3: use nested query predicates with the `Comment` model ```js const comments = await DataStore.query(Comment, c => c.post.id.eq('YOUR_POST_ID')); ```