Model Class
columns()
Signature
Section titled “Signature”columns() — returns array
Available in: model
Category: Miscellaneous Functions
Description
Section titled “Description”Returns an array of columns names for the table associated with this class. Does not include calculated properties that will be generated by the Wheels ORM.
Examples
Section titled “Examples”// 1. Get all column names for the User model
cols = model("User").columns();
// cols -> ["id", "firstName", "lastName", "email", "createdAt", "updatedAt", "deletedAt"]
// 2. Check whether a specific column exists in the table
cols = model("User").columns();
if (arrayFindNoCase(cols, "deletedAt")) {
writeOutput("Soft-delete column is present");
}
// 3. Iterate over all columns and output their names
cols = model("User").columns();
for (col in cols) {
writeOutput(col);
}