November 2018
Intermediate to advanced
404 pages
10h 16m
English
Create the /Source/Application/Controllers directory and add the same JournalController.swift you have used in your myJournal Vapor project to this new directory:
File: /Sources/Application/Controllers/JournalController.swift:
import Foundationfinal class JournalController { var entries : Array<Entry> = Array() //: Get total number of entries func total() -> Int { return entries.count } //: Create a new journal entry func create(_ entry: Entry) -> Entry? { entries.append(entry) return entries.last } //: Read a journal entry func read(index: Int) -> Entry? { if let entry = entries.get(index: index) { return entry } return nil } //: Update the journal entry func update(index: Int, entry: Entry) ...Read now
Unlock full access