> For the complete documentation index, see [llms.txt](https://suhantudor.gitbook.io/crud-node/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://suhantudor.gitbook.io/crud-node/reference/api-reference/groupbydocuments-5.md).

# findDocument 🆕

Find documents by props. Case Insensitive. Returns undefined, if document was not found.

{% hint style="info" %}

```typescript
Throws `errorNoCriteriaProvided` if props are empty.
```

{% endhint %}

**Signature**

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

```javascript
findDocument(session: MySQLSession, props: Partial<IDocument<S>>): Promise<IDocument<S> | undefined>;
```

{% endtab %}

{% tab title="MySQLX" %}

```javascript
findDocument(session: MySQLXSession, props: Partial<IDocument<S>>): Promise<IDocument<S> | undefined>;
```

{% endtab %}
{% endtabs %}

**Example**

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

```javascript
// employeeRouter.{ts|js}
import { employeeController } from './employeeController';

const transacted = true;

await db.usingSession(async (session) => {
  const employeeId = '<id>';
  const data = await employeeController.findDocument(session, { employeeId });
  return data;
}, transacted);
```

{% endtab %}

{% tab title="MySQLX" %}

```javascript
// employeeRouter.{ts|js}
import { employeeController } from './employeeController';

const transacted = true;

await db.usingSession(async (session) => {
  const employeeId = '<id>';
  const data = await employeeController.findDocument(session, { employeeId });
  return data;
}, transacted);
```

{% endtab %}
{% endtabs %}
