![]() The Content protocol is added so that you can use this model in your router. There’s also PostgreSQLModel and PostgreSQLStringModel protocols for models with IDs of type Int or String. The Fluent packages provide Model convenience protocols for each database provider and tell Fluent which type the ID will be. ![]() Next, you’ll add two extensions to Room.swift that make the Room class conform to convenience protocols. The class is marked final to provide performance benefits by the compiler. All Fluent models must conform to Codable. Once the Room has been saved, it’s ID is set. The model class contains a single optional UUID property to hold a room’s unique identifier if it has been set. In Xcode, create a new file within the Sources/App/Models folder, and call the new file Room.swift:Ĭhange the contents of the new file to the following: You’ll start by creating a model class for the conference room data you want to migrate. The steps to connect to Postgres through your Vapor application are already implemented in the starter project in Sources/App/configure.swift.
0 Comments
Leave a Reply. |