The FMPQuery.Builder class is a builder for the FMPQuery class.
class Builder
Method | Description |
database(_:) |
Save object of the database, with which FMPQuery will work, to variable. func database(_ database: FMPDatabase) -> Builder Parameters:
|
select(_:) | Add the SELECT statement to SQL query. func select(_ columns: [String] = ["*"]) -> Builder Parameters:
|
from(_:) | Add the FROM statement to SQL query. func from(_ table: FMPTable) -> Builder Parameters:
|
join(_:type:) | Add the JOIN statement to SQL query.
Parameters:
|
on(_:) | Add the ON statement to SQL query. func on(_ conditions: [String]) -> Builder Parameters:
|
using(_:) | Add the USING statement to SQL query. func using(_ column: String) -> Builder Parameters:
|
where(_:) | Add the WHERE statement to SQL query. func where(_ conditions: [String]) -> Builder Parameters:
|
order(by:) | Add the ORDER BY statement to SQL query. func order(by columns: [(column: String, asc: Bool)]) -> Builder Parameters:
|
limit(_:offset:) | Add the LIMIT statement to SQL query. func limit(_ limit: Int, offset: Int? = nil) -> Builder Parameters:
|
group(by:) | Add the GROUP BY statement to SQL query. func group(by columns: [String]) -> Builder Parameters:
|
having(_:) | Add the HAVING statement to SQL query. func having(_ conditions: [String]) -> Builder Parameters:
|
isResumable(_:) | It sets the use of download resumption on data request from server. func isResumable(_ isResumable: Bool = true) -> Builder Parameters:
|
pathForResume(_:) | Save the path to folder in application directory, which will store download resumption settings, to variable. func pathForResume(_ path: String) -> Builder Parameters:
|
build() | Build an instance of the FMPQuery class. It returns the object of the FMPQuery type. func build() -> FMPQuery |
Build an instance of the FMPQuery class:
// Build an instance of the FMPDatabase class. For details see examples for FMPDatabase.Builder.
let database: FMPDatabase = fmp.database.build()
// Build instances of the FMPTable class. For details see examples for FMPTable.Builder.
let table1: FMPTable = fmp.table.build()
let table2: FMPTable = fmp.table.build()
// Build an instance of the FMPQuery class with the query expression: SELECT column from table1 LEFT JOIN table2 USING(column) WHERE id = 0 AND key = all ORDER BY column ASC
let query: FMPQuery = fmp.query
.database(database) // By default nil
.select(["column"])
.from(table1)
.join(table: table2, type: .left)
.using("column")
.where(["id = 0", "key = all"])
.order(by: [(column: "column", asc: true)])
.isResumable(false) // By default false
.pathForResume("path") // By default ""
.build()
See also: