SQT
A C++ ORM framework for SQLite
Loading...
Searching...
No Matches

◆ SQT_INDEX_2

#define SQT_INDEX_2 ( INDEX_NAME,
INSTANCE_NAME,
... )

Defines an index with the specified names and columns.

Parameters
INDEX_NAMEThe name of the index in the database.
INSTANCE_NAMEThe name of the index instance.
...The names of the columns that form the index. An index can consist of up to 8 columns.

This macro is similar to SQT_INDEX, except that it allows specifying custom index name and instance name for the index. This is useful to map the index to an existing index with the same columns in the database, without creating a new redundant index.

Example usage:

struct MyEntity {
int id{};
std::string name;
};
SQT_TABLE_BEGIN(MyEntityTable, MyEntity)
SQT_COLUMN_FIELD(Name, name)
// Define an index with custom names and the ID and Name columns.
SQT_INDEX_2(MyEntityIndex, Index_ID_Name, ID, Name)
#define SQT_COLUMN_FIELD(COLUMN_NAME, FIELD)
Defines a column that binds to the specified field of the entity type.
Definition table_definition.h:273
#define SQT_INDEX_2(INDEX_NAME, INSTANCE_NAME,...)
Defines an index with the specified names and columns.
Definition table_definition.h:774
#define SQT_TABLE_BEGIN(TABLE_NAME, ENTITY_TYPE)
Begins the definition of a table type for the specified entity type.
Definition table_definition.h:141
#define SQT_TABLE_END
Ends the definition of a table type.
Definition table_definition.h:854

The class name of the index type will be generated by appending the instance name to the prefix IndexType_.

See also
SQT_INDEX