Model with Composite Index

Two Entity Model with Composite Index

The following JSON illustrates the addition of a composite-index to an entity definition. An index composed of the ‘name’ and ‘province’ fields has been declared in the ‘Owner’ entity. This declaration will result in the creation of a non-unique btree index for columns ‘name’ and ‘province’ in the database. Any number of composite indices may be declared for an entity. No relationships have been defined between the two entities; this example simply illustrates how to declare a composite-index for an entity.

{
    "entities":  [
        {
            "typeName": "Owner",
            "properties": {
                "Name": {
                    "type": "string",
                    "format": "", 
                    "required": false,
                    "unique": false,
                    "index": "nonUnique",
                    "selectable": "eq,like"
                },
                "LicenseNumber": {
                    "type": "uint",
                    "format": "", 
                    "required": false,
                    "unique": true,
                    "index": "",
                    "selectable": "eq,lt,gt"
                },
                "Province": {
                    "type": "string",
                    "format": "", 
                    "required": false,
                    "unique": false,
                    "index": "",
                    "selectable": "eq,lt,gt"
                }
            },
            "ext_points": {
                "gen_controller": true,
                "gen_model": true
            },
            "compositeIndexes": [ 
                {"index": "name, province"}
            ]
    },
    {
        "typeName": "Car",
        "properties": {
            "Model": {
                "type": "string",
                "format": "", 
                "required": true,
                "index": "nonUnique",
                "selectable": "eq,like"
            },
            "Make": {
                "type": "string",
                "format": "", 
                "required": true,
                "index": "nonUnique",
                "selectable": "eq,like"
            }
        },
        "ext_points": {
            "gen_controller": true,
            "gen_model": true
        }
    }
    ]
}

The sample model file can be downloaded from the following location: twoEntityWithCompositeIndex.json.