March 2020
Intermediate to advanced
392 pages
10h 10m
English
Let's add an address by following these steps:
import Vaporimport Fluentfinal class Address: Model { static let schema = "addresses" @ID(key: "id") var id: Int? @Field(key: "street") var street: String @Field(key: "city") var city: String @Field(key: "zip") var zip: String @Timestamp(key: "createdAt", on: .create) var createdAt: Date? @Timestamp(key: "updatedAt", on: .update) var updatedAt: Date? @Timestamp(key: "deletedAt", on: .delete) var deletedAt: Date? init() { }}
You can see that we are also storing the basic properties (street, city, zip) in the class. Just as with User, we have given Address the correct dependencies and ...
Read now
Unlock full access