For the complete documentation index, see llms.txt. This page is also available as Markdown.

Contacts.cfc

Create the persistent Contacts ORM entity with primary key, properties, and validation constraints using CommandBox.

Let's use CommandBox to build it:

coldbox create orm-entity entityName=contacts primaryKey=contactID properties=firstName,lastName,email --open

Then spice it up with the validation constraints

/**
* A cool Contact entity
*/
component persistent="true" table="contacts"{

    // Primary Key
    property name="contactID" fieldtype="id" column="contactID" generator="native" setter="false";

    // Properties
    property name="firstName" ormtype="string";
    property name="lastName" ormtype="string";
    property name="email" ormtype="string";

    // validation
    this.constraints = {
        firstName = {required=true},
        lastName = {required=true},
        email = {required=true, type="email"}
    };

}

Last updated

Was this helpful?