Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions guide/getting-started/working-with-entities.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,24 @@ Clones an entity and return an exact copy of the entity. This returned object is
var user = getInstance( "User" );
var clonedUser = user.clone();
```

## fresh

Retrieves a new entity from the database with the same key value as the current entity. The current entity must be loaded (or otherwise have a primary key value), and calling `fresh()` executes a database query to retrieve the latest state.

```javascript
// Load an existing user record (throws if not found)
var user = getInstance( "User" ).findOrFail( 123 );

// Retrieve a fresh copy from the database (executes a DB query)
var freshUser = user.fresh();
```

## refresh

Refreshes the attributes data for the entity with data from the database.

```javascript
var user = getInstance( "User" ).findOrFail( 123 );
var refreshedUser = user.refresh();
```