createIndex

open fun createIndex(entitySet: EntitySet, item: PropertyPath, vararg items: PropertyPath)

Define a database index for an entity set. Must not be called after the local database has been opened (explicitly or implicitly). Actual creation of the index is deferred until the local database is opened (explicitly or implicitly).

See Also:

{@link com.sap.cloud.mobile.kotlin.odata.CloudSyncProvider#open() CloudSyncProvider.open}, {@link com.sap.cloud.mobile.kotlin.odata.EntitySet#indexes EntitySet.indexes}, {@link com.sap.cloud.mobile.kotlin.odata.CloudSyncProvider#createDynamicIndex(kotlin.String, kotlin.String, kotlin.String...) CloudSyncProvider.createDynamicIndex}.

Example using proxy classes:
open fun setupService(): kotlin.Unit
{
    val online = OnlineODataProvider("HealthService",
        "http://health.example.com:8080");
    val database = SQLDatabaseProvider("HealthDB", "jdbc:h2:~/health.h2");
    val offline = CloudSyncProvider(online, database);
    offline.encryptionKey = this.dbEncryptionKey();
    offline.createIndex(HealthService.patients, Patient.dateOfBirth,
        Patient.lastName);
    val service = HealthService(offline);
    service.downloadInGroup("PatientGroup", HealthService.patients,
        HealthService.appointments);
    service.downloadInGroup("StaffGroup", HealthService.doctors,
        HealthService.nurses);
    this.healthService = service;
}

Parameters

entitySet

Entity set for which index will be created.

item

First item to be indexed ({@link com.sap.cloud.mobile.kotlin.odata.Property} or {@link com.sap.cloud.mobile.kotlin.odata.DataPath}).

items

Optional additional items for a composite index.