db: Add methods for searching the database