GetSchema

Retrieve schema information based on current data.

Parameters

  • [optional] ref: Reference to other entities or connections within the transaction.
  • [optional] type: This can be “entities”, “connections”, or “both”. Default is set to “both” when not specified.
  • [optional] refresh: Indicates whether cached data should be returned or schema should be recomputed. Default is true.

Details

If no parameters are provided, it returns refreshed schema information about entities and connections. This can be expensive when there is a sizeable amount of metadata.

Either ref or type can be specified. If the same ref value is used to represent searches on entities as well as connections in a transaction, the Schema will contain information from the entity search.

For more complex searches to find schema for, a Find command must be used first within the transaction. refresh is ignored for calls with ref. When a ref is specified, the schema of the requested objects will be computed (cached will not be used).

Examples

[{
    "GetSchema": {
        "refresh": false
    }
}]

# Response:
[{
    "GetSchema": {
        "status": 0,
        "refreshed": "2021-06-08T16:22:32-09:00",  # timestamp when data was refreshed
        "entities": {
            "returned": 3,  # number of classes matched
            "classes": {
                "Patient": {
                    "properties": {
                        "name": [20, true, String] # [entities with this property, indexed?, type]
                    },
                    "matched": 20
                },
                "Visit": {
                    "properties": {
                        "start_time": [25, true, Time],
                        "end_time":   [25, true, Time]
                    },
                    "matched": 25   # number of entities of this class
                },
                "Doctor": {
                    "properties": {
                        "start_time": [25, true, Time],
                        "end_time":   [25, true, Time]
                    },
                    "matched": 25   # number of entities of this class
                }
            }
        },
        "connections": {
            "returned": 2,
            "classes": {
                "HasVisited": {
                    "src": "Patient",
                    "dst": "Doctor",
                    "properties": {
                        "date_of_visit": [20, true, Time]
                    },
                    "matched": 20
                },
                "related_to": {
                    "src": "Patient",
                    "dst": "Patient",
                    "matched": 20
                }
            }
        }
    }
}]

GetSchema command for “Patient” entities of age greater than 30:

[{
    "FindEntity": {
        "with_class": "Patient",
        "_ref": 1,
        "constraints": {
            "age": [">", 30]
        }
    }
}, {
    "GetSchema": {
        "ref": 1,
    }
}]

# Response:
[{
    "GetSchema": {
        "status": 0,
        "refreshed": "2021-06-09T16:04:32-09:00",
        "entities": {
            "classes": {
                "Patient": {
                    "properties": {
                        "name": [15, true, String]
                    },
                    "matched": 15
                }
            },
            "returned": 1
        }
    }
}]