> For the complete documentation index, see [llms.txt](https://quick.ortusbooks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://quick.ortusbooks.com/13.0.0/guide/getting-started/working-with-entities.md).

# Working with Entities

## isLoaded

Checks if the entity was loaded from the database.

| Name          | Type | Required | Default | Description |
| ------------- | ---- | -------- | ------- | ----------- |
| No parameters |      |          |         |             |

A loaded entity has a tie to the database. It has either been loaded from the database or saved to the database. An unloaded entity is one created in code but not saved to the database yet.

```javascript
var user = getInstance( "User" );
user.isLoaded(); // false
user.save();
user.isLoaded(); // true
```

## clone

Clones the entity and returns an exact copy of the entity.

| Name       | Type    | Required | Default | Description                               |
| ---------- | ------- | -------- | ------- | ----------------------------------------- |
| markLoaded | boolean | false    | false   | Mark the returned entity as loaded or not |

Clones an entity and return an exact copy of the entity. This returned object is a new and separate instance from the original object.

```javascript
var user = getInstance( "User" );
var clonedUser = user.clone();
```

Unlike `replicate`, `clone` includes the primary key. The cloned entity is unloaded unless `markLoaded` is `true`.

## replicate

Creates a new, unloaded entity with the current attributes except for the primary key and any additional attributes you exclude.

| Name   | Type  | Required | Default | Description                                      |
| ------ | ----- | -------- | ------- | ------------------------------------------------ |
| except | array | `false`  | `[]`    | Additional attribute aliases or columns to omit. |

```javascript
var original = getInstance( "Post" ).findOrFail( 1 );
var draft = original
    .replicate( [ "publishedDate" ] )
    .setTitle( "Copy of #original.getTitle()#" )
    .save();
```

Replication fires the [`postReplicate` and `quickPostReplicate` events](/13.0.0/guide/interception-points.md#quickpostreplicate) with both the new `entity` and the `original` entity.

## isDirty

Returns whether the entity has changed since it was loaded or last saved. Pass an attribute alias or column name to inspect one attribute.

```javascript
var user = getInstance( "User" ).findOrFail( 1 );
user.isDirty(); // false

user.setEmail( "new@example.com" );
user.isDirty(); // true
user.isDirty( "email" ); // true
user.isDirty( "username" ); // false
```

## isClean

`isClean` is the inverse of `isDirty` and accepts the same optional attribute argument.

```javascript
user.isClean( "username" ); // true
user.isClean( "email" ); // false
```

## reset

Resets attributes to their originally loaded values and clears loaded relationships. In Quick 13, `reset()` also clears the cached query builder so old query constraints cannot leak into later calls on the entity.

```javascript
var users = getInstance( "User" );
users.whereActive( true );
users.reset();

// The previous where constraint has been cleared.
var allUsers = users.get();
```

Pass `toNew = true`, or call `resetToNew()`, to clear the attributes and mark the entity as unloaded.

## Loaded Primary Keys Are Immutable

Quick prevents changing the primary key of a loaded entity. Assigning a different key throws `QuickPrimaryKeyMutationException` so a later update cannot target one record using another record's identity.

Create a new entity or use `replicate()` when you need a different primary key.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://quick.ortusbooks.com/13.0.0/guide/getting-started/working-with-entities.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
