Simple Two Entity Model

Two Entity Model

The following JSON illustrates the definition of a simple two-entity model file. In this case, model entities ‘Person’ and ‘Country’ will be created in the generated application, along with corresponding database tables ‘person’ and ‘country’. No relationships have been defined between the two entities; this example simply illustrates how to add multiple entity definitions to a model file.

{
    "entities":  [
        {
            "typeName": "Person",
            "properties": {
                "name": {
                    "type": "string",
                    "format": "", 
                    "required": false,
                    "unique": false,
                    "index": "nonUnique",
                    "selectable": "eq,like"
                },
                "age": {
                    "type": "uint",
                    "format": "", 
                    "required": false,
                    "unique": false,
                    "index": "",
                    "selectable": "eq,lt,gt"
                },
                "weight": {
                    "type": "float64",
                    "format": "", 
                    "required": false,
                    "unique": false,
                    "index": "",
                    "selectable": "eq,lt,le,gt,ge"
                },
                "validLicense": {
                    "type": "bool",
                    "format": "", 
                    "required": false,
                    "unique": false,
                    "index": "nonUnique",
                    "selectable": "eq,ne"
                }
            },
            "ext_points": {
                "gen_controller": true,
                "gen_model": true
            }
        },
        {
            "typeName": "Country",
            "properties": {
                "name": {
                    "type": "string",
                    "format": "", 
                    "required": false,
                    "unique": false,
                    "index": "nonUnique",
                    "selectable": "eq,like"
                },
                "isoCode": {
                    "type": "uint",
                    "format": "", 
                    "required": false,
                    "unique": false,
                    "index": "unique",
                    "selectable": "eq,lt,gt"
                }
            },
            "ext_points": {
                "gen_controller": true,
                 "gen_model": true
            }
        }
    ]
}

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