Class
Articles
public final class Articles: Model
Representation of Articles table.
Note that no one depends on anyone at the time of the declaration. This is POJO in Java. Fluent's added functionality is Protocol, so it will be easy to remove and move to another ORMappeer. If possible, it is desirable not even to depend on Protocol.
Extras
Realm is an excellent product, but from this point of view it is very disappointing.😭
Relationships
Conforms To
Model
Initializers
init()
public init()
init(id:slug:title:description:body:author:createdAt:updatedAt:)
public init( id: Int?, slug: String, title: String, description: String, body: String, author: Int, createdAt: Date? = nil, updatedAt: Date? = nil )
Default initializer.
Parameters
Name | Type | Description |
---|---|---|
id | Int? |
A id. |
slug | String |
A slug. |
title | String |
A title. |
description | String |
A description. |
body | String |
A body. |
author | Int |
A author. |
createdAt | Date? |
A created date. |
updatedAt | Date? |
A updated date. |
Properties
schema
public static let schema = "Articles"
id
@ID(custom: .id, generatedBy: .database)
public var id: Int?
A Identifier.
It is assumed that the value is entered on the Database side. The application does not change this value usually.
slug
@Field(key: "slug")
public var slug: String
A slug. https://en.wikipedia.org/wiki/Clean_URL#Slug
createdAt
@Field(key: "createdAt")
public var createdAt: Date?
A created date.
It is assumed that the value is entered on the Database side. The application does not change this value usually.
updatedAt
@Field(key: "updatedAt")
public var updatedAt: Date?
A updated date.
It is assumed that the value is entered on the Database side. The application does not change this value usually.
Methods
create(on:)
public static func create(on database: MySQLDatabase) -> EventLoopFuture<Void>
Execute SQL statement for table creation.
In general, you should use features provided by the following standards: https://docs.vapor.codes/3.0/fluent/models/#create
Parameters
Name | Type | Description |
---|---|---|
connection | A established connection. |