Skip to content

Model Object

reload()

reload() — returns void

Available in: model Category: Miscellaneous Functions

Reloads the property values of this object from the database.

// 1. Reload after a call that may have changed values in the database
employee = model("Employee").findByKey(params.key);
employee.someCallThatChangesValuesInTheDatabase();
employee.reload();

// 2. Discard in-memory changes and restore the current database values
post = model("Post").findByKey(params.id);
post.title = "Draft title that we want to discard";
post.reload();
// post.title now reflects the value stored in the database