Our database models live in their usual folders: Sources/App/Models. Follow the steps given below:
- Open the Sources/App/Models/Database folder, either in Finder or Xcode, and add a new Order.swift file, and enter the following code for the file:
import Fluentimport Vaporfinal class Order: Model { static let schema = "orders" @ID(key: "id") var id: Int? @Field(key: "totalAmount") var totalAmount: Int @Field(key: "paidAmount") var paidAmount: Int @Field(key: "userId") var userId: Int @Field(key: "status") var status: Int @Timestamp(key: "createdAt", on: .create) var createdAt: Date? @Timestamp(key: "updatedAt", on: .update) var updatedAt: Date? @Timestamp(key: "deletedAt", on: .delete) var deletedAt: Date?