macos – Where to find the unread message count in chat.db for messages.app

I’m trying to find the number of unread messages in messages.app. The number should match the number on the badge of the app.

I’ve approached this by accessing chat.db, a sqlite db which lists all data presented and used in the app.

Upon executing select count(*) from message where is_read = 0;, it returns 3694. Checking for 1 returns 3835. The number of unread messages in the app at the time of execution was 0.

Evidentially, I’ve approached this incorrectly. I would appreciate any leads on determining the number of unread messages from the cli, accessing chat.db or not.