Domain Documentation

Enumeration Raw​SQLQueries

public enum RawSQLQueries  

Object that generates raw SQL.

Note

I wanted to get enough information in one query. The reason for using raw query is that the following function was not found in Fluent.

  • Sub query

  • GROUP_CONCAT(MySQL Only)

  • Distinct

  • DELETE JOIN

  • exists

I may have missed it. As an aside, I have never met OR-Mapper, which can cover the vast specifications of SQL. This is part of the reason, I attach importance to portability over typeSafe for OR-Mapper. There is also a growing need to adopt KVS. Database that interacts directly with the application.

Methods

select​Articles(condition:​read​It:​offset:​limit:​)

public static func selectArticles(condition: ArticleCondition, readIt userId: Int?, offset: Int? = nil, limit: Int? = nil) -> String  

Returns the query. Inquires about articles according to the argument conditions.

Parameters

condition Article​Condition

Information that shows what criteria to search for articles.

user​Id Int?

ID of the user reading this article. If nil, following is false.

offset Int?

Search result offset. Nil is not set.

limit Int?

Search result limit. Nil is unlimited.

Returns

SQL query string.

delete​Articles(slug:​)

public static func deleteArticles(slug: String) -> String  

Returns the query. It deletes an article and related tags and favorite information.

Parameters

slug String

Article's slug for delete.

Returns

SQL query string.

select​User(name:​follower:​)

public static func selectUser(name: String, follower id: Int?) -> String  

Returns the query. Inquiries about users and their follow-up information.

Parameters

name String

Username to search for.

id Int?

User's ID searching for the user. If nil, following is false.

Returns

SQL query string.

select​User(id:​follower:​)

public static func selectUser(id userId: Int, follower id: Int?) -> String  

Returns the query. Inquiries about users and their follow-up information.

Parameters

user​Id Int

User's ID to search for.

id Int

User's ID searching for the user. If nil, following is false.

Returns

SQL query string.

select​Comments(for:​read​It:​)

public static func selectComments(for articleSlug: String, readIt userId: Int? = nil) -> String  

Returns the query. Get comments associated with an article.

Parameters

article​Slug String

Article's slug to be commented.

user​Id Int?

User who gets the comment. If nil, following is false.

Returns

SQL query string.

insert​Comments(for:​body:​author:​)

public static func insertComments(for articleSlug: String, body: String, author userId: Int ) -> String  

Returns the query. Inserts a comment associated with an article.

Parameters

article​Slug String

Article's slug to be commented.

body String

A comment body.

user​Id Int

User's ID to comment.

Returns

SQL query string.

delete​Comments(id:​)

public static func deleteComments(id commentId: Int ) -> String  

Returns the query. Delete the comment.

Parameters

comment​Id Int

Comment ID for delete.

Returns

SQL query string.

insert​Follows(followee:​follower:​)

public static func insertFollows(followee username: String, follower id: Int) -> String  

Returns the query. Insert follow information associated with a user.

Parameters

username String

Username to be followed.

id Int

User's Id to follow.

Returns

SQL query string.

delete​Follows(followee:​follower:​)

public static func deleteFollows(followee username: String, follower id: Int) -> String  

Returns the query. Delete follow information associated with a user.

Parameters

username String

Username to be unfollowed.

id Int

User's Id to unfollow.

Returns

SQL query string.

insert​Favorites(for:​by:​)

public static func insertFavorites(for articleSlug: String, by userId: Int) -> String  

Returns the query. Inserts favorite information associated with an article.

Parameters

article​Slug String

Article's slug to be favorited.

user​Id Int

User's Id to favorite.

Returns

SQL query string.

delete​Favorites(for:​by:​)

public static func deleteFavorites(for articleSlug: String, by userId: Int) -> String  

Returns the query. This deletes favorite information associated with an article.

Parameters

article​Slug String

Article's slug to be unfavorited.

user​Id Int

User's Id to unfavorite.

Returns

SQL query string.

select​Tags()

public static func selectTags() -> String  

Returns the query. It returns the tag registered in the database as unique.

Returns

SQL query string.