The data model used in the SQLite database is implemented in /Models/Todo.swift:
// File: /Sources/App/Models/Todo.swift
import FluentSQLite
import Vapor
/// A single entry of a Todo list.
final class Todo: SQLiteModel { // [1]
/// The unique identifier for this `Todo`.
var id: Int? // [2]
/// A title describing what this `Todo` entails.
var title: String // [3]
/// Creates a new `Todo`.
init(id: Int? = nil, title: String) { // [4]
self.id = id
self.title = title
}
}
/// Allows `Todo` to be used as a dynamic migration.
extension Todo: Migration { } // [5]
/// Allows `Todo` to be encoded to and decoded from HTTP messages.
extension Todo: Content { } // [6]
/// Allows `Todo` to be used as a dynamic parameter in route definitions.
extension Todo: Parameter { } // [7]
The data model is implemented as follows:
- The final ToDo class is subclassing from the SQLiteModel class
- The id...