Module: SQLite-StORM
extension SQLiteStORM
func delete() throws
Deletes one row, with an id
Presumes first property in class is the id.
func delete(_ id: Any) throws
Deletes one row, with the id as set.
func get(_ id: Any) throws
Retrieves a single row with the supplied ID.
func get() throws
Retrieves a single row with the ID as set.
func find(_ data: [(String, Any)]) throws
Performs a find on mathing column name/value pairs.
func find(_ data: [String: Any]) throws
Performs a find on mathing column name/value pairs.
extension SQLiteStORM
func insert(_ data: [(String, Any)]) throws -> Any
Insert function where the suppled data is in [(String, Any)] format.
func insert(cols: [String], params: [Any]) throws -> Any
Insert function where the suppled data is in matching arrays of columns and parameter values.
extension SQLiteStORM
func findAll() throws
Retrieves all rows in the table, only limited by the cursor (9,999,999 rows)
func select(
whereclause: String,
params: [Any],
orderby: [String],
cursor: StORMCursor = StORMCursor(),
joins: [StORMDataSourceJoin] = [],
having: [String] = [],
groupBy: [String] = []
) throws
Select function with specific where clause.
Parameterized statements are used, so all params should be passed in using the [Any] params array.
The whereclause should be specified in the following format: "name = $1 AND email LIKE $2"
An orderby array can be specified in a String array like ["name DESC","email ASC"]
A StORMCursor can be supplied, otherwise the default values are used.
Note that the joins, having and groupBy functionality is unimplemented at this time.
The select function will populate the object with the results of the query.
func select(
columns: [String],
whereclause: String,
params: [Any],
orderby: [String],
cursor: StORMCursor = StORMCursor(),
joins: [StORMDataSourceJoin] = [],
having: [String] = [],
groupBy: [String] = []
) throws
Select function with specific where clause, and spefified columns to return.
Parameterized statements are used, so all params should be passed in using the [Any] params array.
The whereclause should be specified in the following format: "name = $1 AND email LIKE $2"
An orderby array can be specified in a String array like ["name DESC","email ASC"]
A StORMCursor can be supplied, otherwise the default values are used.
Note that the joins, having and groupBy functionality is unimplemented at this time.
The select function will populate the object with the results of the query.
extension SQLiteStORM
func sql(_ statement: String, params: [String]) throws -> [SQLiteStmt]
Execute Raw SQL statement with parameter binding from the params array.
Returns an array of [SQLiteStmt]
func sqlAny(_ statement: String, params: [String]) throws -> Any
Execute Raw SQL statement with parameter binding from the params array.
Returns an ID column
func sqlRows(_ statement: String, params: [String]) throws -> [StORMRow]
Execute Raw SQL statement with parameter binding from the params array.
Returns an array of [StORMRow]
struct SQLiteConnector
SQLiteConnector sets the connection parameters for the SQLite3 database file access
Usage:
SQLiteConnector.db = "XXXXXX"
static var db = ""
Holds the location of the db file.
extension SQLiteStORM
func update(cols: [String], params: [Any], idName: String, idValue: Any) throws -> Bool
Updates the row with the specified data.
This is an alternative to the save() function.
Specify matching arrays of columns and parameters, as well as the id name and value.
func update(data: [(String, Any)], idName: String = "id", idValue: Any) throws -> Bool
Updates the row with the specified data.
This is an alternative to the save() function.
Specify a [(String, Any)] of columns and parameters, as well as the id name and value.