> For the complete documentation index, see [llms.txt](https://coldbox.ortusbooks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://coldbox.ortusbooks.com/ecosystem/data-and-persistence.md).

# Data & Persistence

Database access in ColdBox — ORM options (BoxLang ORM, cborm, Quick), the qb query builder, and cfmigrations.

ColdBox is persistence-agnostic: you choose the data layer per project. The ecosystem offers three ORM paths, a fluent query builder, and migrations.

## Choosing an ORM

| Option                     | Engine                       | Best for                                                              |
| -------------------------- | ---------------------------- | --------------------------------------------------------------------- |
| **BoxLang ORM** (`bx-orm`) | BoxLang                      | New BoxLang apps — native, first-class                                |
| **cborm**                  | Adobe / Lucee / BoxLang-CFML | Existing Hibernate ORM apps, virtual service layers, criteria queries |
| **Quick**                  | All                          | Lightweight entity ORM without Hibernate                              |

```bash
box install bx-orm      # BoxLang native
box install cborm       # Hibernate-based
box install quick       # Lightweight entities
```

📖 **Full documentation:** [bxorm.ortusbooks.com](https://bxorm.ortusbooks.com) · [cborm.ortusbooks.com](https://cborm.ortusbooks.com) · [quick.ortusbooks.com](https://quick.ortusbooks.com)

### Quick Example (Quick)

{% tabs %}
{% tab title="BoxLang" %}

```javascript
// models/User.bx
class extends="quick.models.BaseEntity" {

    property name="email"
    property name="name"

}
```

{% endtab %}

{% tab title="CFML" %}

```javascript
// models/User.cfc
component extends="quick.models.BaseEntity" {

    property name="email"
    property name="name"

}
```

{% endtab %}
{% endtabs %}

```javascript
// In a handler or service
property name="userService" inject="quickService:User";

users = userService.where( "active", true ).orderBy( "name" ).get()
user  = userService.findOrFail( rc.id )
```

## qb — Fluent Query Builder

When an ORM is more than you need, **qb** gives you expressive, injection-safe SQL:

```bash
box install qb
```

```javascript
property name="query" inject="QueryBuilder@qb";

var activeUsers = query.from( "users" )
    .where( "active", true )
    .orderBy( "created", "desc" )
    .limit( 20 )
    .get()
```

📖 **Full documentation:** [qb.ortusbooks.com](https://qb.ortusbooks.com)

## cfmigrations — Versioned Schema Changes

```bash
box install cfmigrations
```

```bash
# Create and run migrations
migrate create create_users_table
migrate up
```

Migrations keep schema changes in source control and apply them consistently across environments — the same files power [CbGenesis](https://cbgenesis.coldbox.org), our production starter template.

📖 **Full documentation:** [cfmigrations.ortusbooks.com](https://cfmigrations.ortusbooks.com)

## See Also

* [Serialization](/ecosystem/serialization.md) — turning entities into API responses
* [Models](/the-basics/models.md) — the service layer and dependency injection
* [Testing Tools](/ecosystem/ecosystem.md#developer-tools) — `cbMockData` for seeding test data


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://coldbox.ortusbooks.com/ecosystem/data-and-persistence.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
