Model Class
Model Class
average()— Calculates the average value for a given property.columnDataForProperty()— Returns a struct containing metadata about a specific property in a model. This includes information such as type, constcolumnForProperty()— Returns the database column name that corresponds to a given model property. This is useful when your model property namcolumnNames()— Returns a list of column names for the table mapped to this model. The list is ordered according to the columns’ ordinalcolumns()— Returns an array of database column names for the table associated with the model. This method excludes calculated or trcount()— The count() method calculates the number of records in a table that match a given set of conditions. It internally usescreate()— The create() method is used to instantiate a new model object, set its properties, and save it to the database (if validdeleteAll()— Deletes all records that match thewhereargument.deleteByKey()— Finds the record with the supplied key and deletes it.deleteOne()— Finds a single record based on conditions and deletes it. Returns true if deletion succeeds, false otherwise. It is usefexists()— Checks if a record exists in the table.findAll()— Returns records from the database table mapped to this model according to the arguments passed in (use thewhere</findAllKeys()— The findAllKeys() function retrieves all primary key values for a model’s records and returns them as a list. By defaultfindByKey()— The findByKey() function retrieves a single record from the database using its primary key value and returns it as an obfindFirst()— The findFirst() function fetches the first record from the database table mapped to the model, ordered by the primary kefindLastOne()— The findLastOne() function fetches the last record from the database table mapped to the model, ordered by the primary kfindOne()— Fetches the first record found based on theWHEREandORDER BYclauses.getTableNamePrefix()— Returns the table name prefix that is set for the current model. This is useful when your database tables share a commoninvokeWithTransaction()— Runs a specified model method inside a single database transaction. This ensures that all database operations within theisClass()— Determines whether the method is being called at the class level (on the model itself) or on an instance of the model. TisInstance()— Checks whether the current context is an instance of a model object rather than a class-level context. This is useful whmaximum()— Calculates the maximum value for a given property.minimum()— Calculates the minimum value for a specified property in a model using SQL’s MIN() function. This can be used to find thnew()— Creates a new object based on suppliedpropertiesand returns it.onMissingMethod()— This method is not designed to be called directly from your code, but provides functionality for dynamic finders such asprimaryKey()— Returns the name of the primary key column for the table mapped to a given model. Wheels determines this automatically bprimaryKeys()— Alias forprimaryKey().propertyNames()— Returns a list of all property names associated with a model. The list is ordered by the columns’ ordinal positions as tsave()— Saves the current model object to the database, with Wheels automatically determining whether to perform an INSERT for nsum()— Calculates the total of all values for a given property (column) using SQL’sSUM()function. It’s typicallytableName()— Returns the name of the database table that a model is mapped to. Wheels automatically determines the table name based oupdateAll()— Updates all properties for the records that match thewhereargument.updateByKey()— Finds the object with the suppliedkeyand saves it (if validation permits it) with the suppliedpropupdateOne()— Retrieves a single model object based on the supplied arguments and updates it with the specified properties. It returnsvalidationTypeForProperty()— Returns the type of validation that Wheels would apply for a given property. This is useful if you want to dynamically i