Skip to content

Model Class

columnDataForProperty()

columnDataForProperty() — returns any

Available in: model Category: Miscellaneous Functions

Returns a struct containing metadata about a specific property in a model. This includes information such as type, constraints, default values, and other column-specific details. It’s useful when you need to introspect the schema of your model dynamically.

NameTypeRequiredDefaultDescription
propertystringyesName of property to inspect.
1. Inspect a simple property
user = model("user").columnDataForProperty("email");

writeDump(user);

Output might include:
{
  "column": "email",
  "dataType": "string",
  "columnDefault": "",
  "nullable": "NO",
  "size": 255
}

2. Use column metadata for validation or dynamic forms
columns = model("product").columnDataForProperty("price");

if(columns.nullable EQ "NO" AND columns.dataType EQ "decimal") {
    writeOutput("Price is required and must be decimal.");
}