Hands-On Server-Side Web Development with Swift
上QQ阅读APP看书,第一时间看更新

Retrieving all entries

Append the getTotal() function to the line right after boot(router:):

func getTotal(_ req: Request) -> String {
let total = journal.total()
print("Total Records: \(total)")
return "\(total)"
}

The function simply calls the JournalController total() function and return the total count of entries.