I'm learning about Collections, Repositories and DTO, and I'm still trying to figure out what's the best way to query a table to fetch data. I also found that we can use \Magento\Framework\App\ResourceConnection for direct SQL queries.
My question is:
Which way should I use for future projects, since my goal is to use table data to create APIs and also frontend pages? Is there a better way for each case?