Skip to content

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, const
  • columnForProperty() — Returns the database column name that corresponds to a given model property. This is useful when your model property nam
  • columnNames() — Returns a list of column names for the table mapped to this model. The list is ordered according to the columns’ ordinal
  • columns() — Returns an array of database column names for the table associated with the model. This method excludes calculated or tr
  • count() — The count() method calculates the number of records in a table that match a given set of conditions. It internally uses
  • create() — The create() method is used to instantiate a new model object, set its properties, and save it to the database (if valid
  • deleteAll() — Deletes all records that match the where argument.
  • 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 usef
  • exists() — 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 the where</
  • findAllKeys() — The findAllKeys() function retrieves all primary key values for a model’s records and returns them as a list. By default
  • findByKey() — The findByKey() function retrieves a single record from the database using its primary key value and returns it as an ob
  • findFirst() — The findFirst() function fetches the first record from the database table mapped to the model, ordered by the primary ke
  • findLastOne() — The findLastOne() function fetches the last record from the database table mapped to the model, ordered by the primary k
  • findOne() — Fetches the first record found based on the WHERE and ORDER BY clauses.
  • getTableNamePrefix() — Returns the table name prefix that is set for the current model. This is useful when your database tables share a common
  • invokeWithTransaction() — Runs a specified model method inside a single database transaction. This ensures that all database operations within the
  • isClass() — Determines whether the method is being called at the class level (on the model itself) or on an instance of the model. T
  • isInstance() — Checks whether the current context is an instance of a model object rather than a class-level context. This is useful wh
  • maximum() — 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 th
  • new() — Creates a new object based on supplied properties and returns it.
  • onMissingMethod() — This method is not designed to be called directly from your code, but provides functionality for dynamic finders such as
  • primaryKey() — Returns the name of the primary key column for the table mapped to a given model. Wheels determines this automatically b
  • primaryKeys() — Alias for primaryKey().
  • propertyNames() — Returns a list of all property names associated with a model. The list is ordered by the columns’ ordinal positions as t
  • save() — Saves the current model object to the database, with Wheels automatically determining whether to perform an INSERT for n
  • sum() — Calculates the total of all values for a given property (column) using SQL’s SUM() function. It’s typically
  • tableName() — Returns the name of the database table that a model is mapped to. Wheels automatically determines the table name based o
  • updateAll() — Updates all properties for the records that match the where argument.
  • updateByKey() — Finds the object with the supplied key and saves it (if validation permits it) with the supplied prop
  • updateOne() — Retrieves a single model object based on the supplied arguments and updates it with the specified properties. It returns
  • validationTypeForProperty() — Returns the type of validation that Wheels would apply for a given property. This is useful if you want to dynamically i