The M function is a short-hand to create both record and collection objects. The first argument is reqruied and has to be one of the model name existed in your application. For example, this creates an blank record object of Book model:

$book = M("Book");

It's said to be blank because it is not associated with a record stored in the database, and does not have any meaningful properties. However, it is useful to create records with this representation:

Thanks to the design of Jifty::DBI::Record, which allows record creations with both object method and class method.

The M function optionally takes a list of key-value pairs after model names. The keys will be treated as column names, as values are, of course, column values. These key-value pairs will be the requirement used to load records. For example, this statement loads a record of Book with certain isbn:

Optionally, JiftyX::ModelHelpers generates two functions for each models your Jifty application. One for accessing records, the other for accessing collections. For example, if you have a model named "Book", the generated functions are:

JiftyX::ModelHelpers::Book
JiftyX::ModelHelpers::BookCollection

They are imported to your currenct package scope as:

Book
BookCollection

The are generated and imported when you say:

use JiftyX::ModelHelpers;

The record function takes either exact one argument or a hash. When it is given only one argument, that argument is treated as the value of "id" field and the record with that id is retured. Such as:

Please also read the description of load_by_cols in Jifty::DBI::Record to know how to use it. Basically the generate helper functions just delegate all its argument to that method and returns whatever returned from there.

The returned $book is a Jifty::Record object, so please read its POD for how to use it.

As for the function of collections, here's the example to get a collection of all records of books: