> For the complete documentation index, see [llms.txt](https://serafim.gabrielhk.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://serafim.gabrielhk.dev/readme.md).

# Introduction

**Se**arch **R**equests **A**PI for TypeORM's **Fi**nd **M**ethod.

Serafim turns a small, JSON-friendly notation into the `where`, `relations` and `order` parameters that TypeORM's `find` method expects — so a frontend can describe *what* to fetch without the backend knowing the query shape in advance.

```ts
import { getWhere, getRelations, getOrder, AND, OperationTypesEnum } from "serafim";

const where = AND(
  { field: "person.address.state", searchTerm: "NY" },
  { field: "age", operation: OperationTypesEnum.GREATER_EQUAL, searchTerm: 18 }
);

userRepository.find({
  relations: getRelations(where), // { person: { address: true } }
  where: getWhere(where),         // parameterized TypeORM conditions
  order: getOrder({ field: "person.address.state", sortOrder: "ASC" }),
});
```

## Contents

* [Getting started](/getting-started.md) — install and a first query.
* [Core concepts](/core-concepts.md) — `Search`, `Where`, conditions, and how `AND` / `OR` combine them.
* [Operators](/operators.md) — every operator, the SQL it produces, and the `searchTerm` each one expects.
* [AND & OR](/or-and-and.md) — combining conditions and how they map to TypeORM.
* [API reference](/api-reference.md) — functions, classes, enums and types.
* [Examples](/examples.md) — common recipes.
* [Migrating to v3](/migration-to-v3.md) — what changed from 2.x and how to update.

## What's new in 3.x

* **Injection-safe by design.** Every `searchTerm` is bound as a query parameter via TypeORM's native operators (`Equal`, `In`, `Like`, `Between`, …) — never concatenated into raw SQL.
* **Explicit combination only.** Conditions are combined with `AND(...)` / `OR(...)`. Bare arrays are no longer accepted and throw a descriptive error.
* **Clean operator semantics.** `NULL` / `IS` → `IS NULL`, `NOT` → `IS NOT NULL`, `TRUE` / `FALSE` → `IS TRUE` / `IS FALSE`, and invalid inputs (e.g. `IN` without an array) throw instead of producing broken SQL.

See [Migrating to v3](/migration-to-v3.md) for the full list.


---

# 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:

```
GET https://serafim.gabrielhk.dev/readme.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
