[db] refactors the API to prevent direct modificaiton of ViewItems
[db] TypedDict makes sure the queries are for the correct type now