TableInterface
public protocol TableInterface
Convenient interface for table related operation
-
create(table:of:)
Default implementationCreate table, related indexes and constraints with specific type
Note that it will create defined indexes automatically. The name of index is
"\(tableName)\(indexSubfixName)"
whileindexSubfixName
is defined byIndexBinding
. BUT, it will not drop the undefined indexes. You should drop it manually.Note that it will add the newly defined column automatically. AND, it will skip the undefined column. It can be very developer-friendly while upgrading your database column.
Note that it will run embedded transaction
The embedded transaction means that it will run a transaction if it’s not in other transaction, otherwise it will be executed within the existing transaction.Throws
Error
Default Implementation
Declaration
Swift
func create<Root: TableEncodable>(table name: String, of rootType: Root.Type) throws
Parameters
name
Table name.
rootType
Type of table encodable object
-
create(virtualTable:of:)
Default implementationCreate virtual table and constraints with specific type
Note that it will run embedded transaction
The embedded transaction means that it will run a transaction if it’s not in other transaction, otherwise it will be executed within the existing transaction.Throws
Error
Default Implementation
Declaration
Swift
func create<Root: TableEncodable>(virtualTable name: String, of rootType: Root.Type) throws
Parameters
name
Table name.
rootType
Type of table encodable object
-
Create table manually
Throws
Error
Declaration
Swift
func create(table name: String, with columnDefList: [ColumnDef], and constraintList: [TableConstraint]?) throws
Parameters
name
Table name
columnDefList
WINQ column definition list
constraintList
WINQ constraint list.
-
Create table manually
Throws
Error
Declaration
Swift
func create(table name: String, with columnDefList: ColumnDef..., and constraintList: [TableConstraint]?) throws
Parameters
name
Table name
columnDefList
WINQ column definition list
constraintList
WINQ constraint list.
-
addColumn(with:forTable:)
Default implementationCreate new column
Throws
Error
Default Implementation
Declaration
Swift
func addColumn(with columnDef: ColumnDef, forTable table: String) throws
Parameters
columnDef
WINQ column definition
table
Table name
-
drop(table:)
Default implementationDrop table
Throws
Erro
Default Implementation
Declaration
Swift
func drop(table name: String) throws
Parameters
name
Table name
-
Create index manually
Throws
Error
Declaration
Swift
func create(index name: String,
Parameters
name
Index name
columnIndexConvertibleList
WINQ column index list
table
Table name
-
Create index manually
Throws
Error
Declaration
Swift
func create(index name: String,
Parameters
name
Index name
columnIndexConvertibleList
WINQ column index list
table
Table name
-
drop(index:)
Default implementationDrop index
Throws
Error
Default Implementation
Declaration
Swift
func drop(index name: String) throws
Parameters
name
Index name