Domain Documentation

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.😭

Articles Articles Model Model Articles->Model

Conforms To

Model

Initializers

init()

public init()  

init(id:​slug:​title:​description:​body:​author:​created​At:​updated​At:​)

public init( id: Int?, slug: String, title: String, description: String, body: String, author: Int, createdAt: Date? = nil, updatedAt: Date? = nil )  

Default initializer.

Parameters

id Int?

A id.

slug String

A slug.

title String

A title.

description String

A description.

body String

A body.

author Int

A author.

created​At Date?

A created date.

updated​At 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

title

@Field(key: "title")
    public var title: String

A title.

description

@Field(key: "description")
    public var description: String

A description.

body

@Field(key: "body")
    public var body: String

A body.

author

@Parent(key: "author")
    public var author: Users

A author. It's a Users's id.

created​At

@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.

updated​At

@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.

tags

@Children(for: \.$article)
    public var tags: [Tags] 

Tags on articles as Tags

favorites

@Children(for: \.$article)
    public var favorites: [Favorites] 

Favorites this article

comments

@Children(for: \.$article)
    public var comments: [Comments] 

Comments this article

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

connection

A established connection.