Model Object
isPersisted()
Signature
Section titled “Signature”isPersisted() — returns boolean
Available in: model
Category: Miscellaneous Functions
Description
Section titled “Description”Returns true if this object has been persisted to the database or was loaded from the database via a finder.
Returns false if the record has not been persisted to the database.
Examples
Section titled “Examples”1. Check an older object
employee = model("employee").findByKey(123);
if (employee.isPersisted()) {
writeOutput("This employee exists in the database.");
} else {
writeOutput("This employee has not been saved yet.");
}
2. Creating a new object
newEmployee = model("employee").new();
if (!newEmployee.isPersisted()) {
writeOutput("This is a new object, not yet persisted.");
}