November 2018
Intermediate to advanced
404 pages
10h 16m
English
For simplicity, your myJournal application persists data in memory. You'll use database operations for permanent data storage later on.
Even though you are not using a database operation, you'll implement the typical Create, Read, Update, and Delete (CRUD) operations for your data. Create the JournalController.swift file in the /Sources/App/Controllers directory:
// Journal controllerimport Vaporfinal class JournalController { var entries : Array<Entry> = Array() // [1] //: Get total number of entries func total() -> Int { // [2] return entries.count } //: Create a new journal entry func create(_ entry: Entry) -> Entry? { // [3] entries.append(entry) return entries.last } //: Read a journal entry ...Read now
Unlock full access