> For the complete documentation index, see [llms.txt](https://cross-packages.gitbook.io/cross-api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cross-packages.gitbook.io/cross-api/services/find-by.md).

# FindBy

Receives any parameter as an argument as long as it is a { key: value } or array of { key: value }.

**For simple queries:**

```typescript
const example = await this.examplesRepository.findBy(
  { where: { id: 123 } },
  trx,
);

// Find one where id = 123
```

**For queries composed of more than one condition:**

```typescript
const example = await this.examplesRepository.findBy(
  { where: { id: 123, name: "example" } },
  trx,
);

// Find one where id = 123 AND name = "example"
```

**For queries composed of one condition or another:**

```typescript
const example = await this.examplesRepository.findBy(
  {
    where: [
      { id: 123 },
      { name: "example" },
    ],
  },
  trx,
);

/** Find one where id = 123 OR name = "example"
 * You also can use a mapper to make your work easier and cleaner
 * There will be an introduction about them right under the standard queries introduction
 */
```

**In addition, it can be passed as array of string keys of relations that you want to load and the fields you want to select:**

```typescript
const select = { name: true }

const example = await this.examplesRepository.findBy(
  {
    where: { id: 123 },
    relations: ["relation-1", "relation-2"], // or { "relation-1": true, "relation-2": true }
    select,
  },
  trx,
);

// Find one where id = 123 and load related relation-1 and relation-2 entities
```

***
