# searchDocuments 🆕

{% hint style="info" %}

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

{% endhint %}

**Signature**

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

```javascript
searchDocuments(session: MySQLSession, props: Partial<IDocument<S>>, join?: 'OR' | 'AND', pagination?: IOffsetPagination, sort?: Sort): Promise<IPaginatedSet<IDocument<S>>>;
```

{% endtab %}

{% tab title="MySQLX" %}

```javascript
searchDocuments(session: MySQLXSession, props: Partial<IDocument<S>>, join?: 'OR' | 'AND', pagination?: IOffsetPagination): Promise<IPaginatedSet<IDocument<S>>>;
```

{% endtab %}
{% endtabs %}

**Example**

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

```javascript
// officeRouter.{ts|js}
import { officeController } from './officeController';
import { OfficeProps } from './schemas/office';

const transacted = true;

await db.usingSession(async (session) => {
  const data = await officeController.searchDocuments(
    session,
    {
      name: '%coworking%',
      officeCode: '%coworking%',
    },
    'OR',
  );
  return data;
}, transacted);
```

{% endtab %}

{% tab title="MySQLX" %}

```javascript
// officeRouter.{ts|js}
import { officeController } from './officeController';
import { OfficeProps } from './schemas/office';

const transacted = true;

await db.usingSession(async (session) => {
  const data = await officeController.searchDocuments(
    session,
    {
      name: '%coworking%',
      officeCode: '%coworking%',
    },
    'OR',
  );
  return data;
}, transacted);
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: 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://suhantudor.gitbook.io/crud-node/reference/api-reference/searchdocuments.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.
