WCTTransaction Class Reference
Inherits from | WCTInterface : WCTCore : NSObject |
---|---|
Declared in | WCTTransaction.h |
Other Methods
– begin
Begin this transaction.
- (BOOL)begin
Return Value
YES only if no error occurs.
Declared In
WCTTransaction.h
– commit
Commit this transaction.
- (BOOL)commit
Return Value
YES only if no error occurs.
Declared In
WCTTransaction.h
– rollback
Rollback this transaction.
- (BOOL)rollback
Return Value
YES only if no error occurs.
Declared In
WCTTransaction.h
– runTransaction:event:
Run a transaction in block.
BOOL committed = [transaction runTransaction:^BOOL(){
BOOL result = [transaction insertObject:object into:tableName];
return result;//return YES to commit transaction and return NO to rollback transaction.
} event:^(WCTTransactionEvent event) {
switch (event) {
case WCTTransactionEventBeginFailed:
break;
case WCTTransactionEventCommitFailed:
break;
case WCTTransactionEventRollback:
break;
case WCTTransactionEventRollbackFailed:
break;
};
}];
- (BOOL)runTransaction:(WCTTransactionBlock)inTransaction event:(WCTTransactionEventBlock)onTransactionStateChanged
Parameters
inTransaction |
Operation inside transaction. |
---|---|
onTransactionStateChanged |
State changed event. |
Return Value
YES only if transaction is committed.
Declared In
WCTTransaction.h
– runTransaction:
This interface is equivalent to [transaction runTransaction:transaction event:nil];
- (BOOL)runTransaction:(WCTTransactionBlock)inTransaction
Parameters
inTransaction |
Operation inside transaction. |
---|
Return Value
YES only if transaction is committed.
See Also
Declared In
WCTTransaction.h
– changes
It should be called after executing successfully
- (int)changes
Return Value
the number of changes in the most recent call
Declared In
WCTTransaction.h
Statistics Methods
– error
More detailed error messages.
- (WCTError *)error
Return Value
nil or error.isOK==YES if no error occurs.
Discussion
More detailed error messages.
Declared In
WCTTransaction+Statistics.h
– setStatisticsEnabled:
After enabling, you can call the [cost] interface to get time consuming. Note that you should call it before calling all other interface, otherwise [cost] will return an inaccurate result. See [cost] also.
- (void)setStatisticsEnabled:(BOOL)enabled
Parameters
enabled |
enabled |
---|
Discussion
After enabling, you can call the [cost] interface to get time consuming. Note that you should call it before calling all other interface, otherwise [cost] will return an inaccurate result. See [cost] also.
Declared In
WCTTransaction+Statistics.h
– cost
The time consuming. You can call it to profile the performance. See [setStatisticsEnabled:] also.
- (double)cost
Return Value
Time in seconds
Discussion
The time consuming. You can call it to profile the performance. See [setStatisticsEnabled:] also.
Declared In
WCTTransaction+Statistics.h
Table Methods
– createTableAndIndexesOfName:withClass:
Create table and indexes from ORM. Note that it will add newly defined column automatically. 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.
- (BOOL)createTableAndIndexesOfName:(NSString *)tableName withClass:(Class<WCTTableCoding>)cls
Parameters
tableName |
The name of the table to be created. |
---|---|
cls |
class |
Return Value
YES only if no error occurs.
Discussion
Create table and indexes from ORM. Note that it will add newly defined column automatically. 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.
Declared In
WCTTransaction+Table.h
– createVirtualTableOfName:withClass:
Create virtual table from ORM.
- (BOOL)createVirtualTableOfName:(NSString *)tableName withClass:(Class<WCTTableCoding>)cls
Parameters
tableName |
The name of the virtual table to be created. |
---|---|
cls |
class |
Return Value
YES only if no error occurs.
Discussion
Create virtual table from ORM.
Declared In
WCTTransaction+Table.h
– createTableOfName:withColumnDefList:andConstraintList:
Create table from user-defined column.
- (BOOL)createTableOfName:(NSString *)tableName withColumnDefList:(const WCTColumnDefList &)columnDefList andConstraintList:(const WCTTableConstraintList &)constraintList
Parameters
tableName |
The name of the table to be created. |
---|---|
columnDefList |
The list of column definition. |
constraintList |
The list of constraint. |
Return Value
YES only if no error occurs.
Discussion
Create table from user-defined column.
Declared In
WCTTransaction+Table.h
– createTableOfName:withColumnDefList:
This interface is equivalent to [database createTableOfName:tableName withColumnDefList:columnDefList andConstraintList:{}].
- (BOOL)createTableOfName:(NSString *)tableName withColumnDefList:(const WCTColumnDefList &)columnDefList
Parameters
tableName |
The name of the table to be created. |
---|---|
columnDefList |
The list of column definition. |
Return Value
YES only if no error occurs.
Discussion
This interface is equivalent to [database createTableOfName:tableName withColumnDefList:columnDefList andConstraintList:{}].
Declared In
WCTTransaction+Table.h
– isTableExists:
Check whether table exists
- (BOOL)isTableExists:(NSString *)tableName
Parameters
tableName |
The name of the table to be checked. |
---|
Return Value
YES if table exists. NO if table does not exist or an error occurs.
Discussion
Check whether table exists
Declared In
WCTTransaction+Table.h
– dropTableOfName:
Drop table.
- (BOOL)dropTableOfName:(NSString *)tableName
Parameters
tableName |
The name of the table to be dropped. |
---|
Return Value
YES only if no error occurs.
Discussion
Drop table.
Declared In
WCTTransaction+Table.h
– createIndexOfName:withIndexList:forTable:
Create table from user-defined index.
- (BOOL)createIndexOfName:(NSString *)indexName withIndexList:(const WCTIndexList &)indexList forTable:(NSString *)tableName
Parameters
indexName |
The name of the index to be created. |
---|---|
indexList |
The list of index definition. |
tableName |
The name of index-associated table. |
Return Value
YES only if no error occurs.
Discussion
Create table from user-defined index.
Declared In
WCTTransaction+Table.h
– dropIndexOfName:
Drop index.
- (BOOL)dropIndexOfName:(NSString *)indexName
Parameters
indexName |
The name of the index to be dropped. |
---|
Return Value
YES only if no error occurs.
Discussion
Drop index.
Declared In
WCTTransaction+Table.h
– addColumn:forTable:
Add column.
- (BOOL)addColumn:(const WCTColumnDef &)columnDef forTable:(NSString *)tableName
Parameters
columnDef |
The definition of column to be added. |
---|---|
tableName |
The name of table to do a column addition. |
Return Value
YES only if no error occurs.
Discussion
Add column.
Declared In
WCTTransaction+Table.h