2021-07-22 23:28:01 -07:00
|
|
|
package data
|
|
|
|
|
2022-03-06 17:26:52 -08:00
|
|
|
// GetMessagesCount will return the number of messages in the database.
|
|
|
|
func GetMessagesCount() int64 {
|
|
|
|
query := `SELECT COUNT(*) FROM messages`
|
|
|
|
rows, err := _db.Query(query)
|
|
|
|
if err != nil || rows.Err() != nil {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
defer rows.Close()
|
|
|
|
var count int64
|
|
|
|
for rows.Next() {
|
|
|
|
if err := rows.Scan(&count); err != nil {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return count
|
|
|
|
}
|