> ## Documentation Index
> Fetch the complete documentation index at: https://docs.corsair.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Database

> Gmail local sync: searchable entities, `.search()` filters, and operators.

The Gmail plugin syncs data locally. Use `corsair.gmail.db.<entity>.search({ data, limit?, offset? })` with the filters listed per entity.

<Info>
  **New to Corsair?** See [database operations](/concepts/database), [data synchronization](/concepts/integrations), and [multi-tenancy](/concepts/multi-tenancy).
</Info>

## Drafts

Path: `gmail.db.drafts.search`

```ts theme={null}
const rows = await corsair.gmail.db.drafts.search({
    data: { /* filters below */ },
    limit: 100,
    offset: 0,
});
```

### Searchable filters

| Field       | Type     | Operators                                  |
| ----------- | -------- | ------------------------------------------ |
| `entity_id` | `string` | equals, contains, startsWith, endsWith, in |
| `id`        | `string` | equals, contains, startsWith, endsWith, in |
| `messageId` | `string` | equals, contains, startsWith, endsWith, in |
| `createdAt` | `date`   | equals, before, after, between             |

*Every `.search()` also accepts `limit` and `offset` for pagination. `.list()` is available on the same path without the `.search` suffix in code — see [database operations](/concepts/database).*

***

## Labels

Path: `gmail.db.labels.search`

```ts theme={null}
const rows = await corsair.gmail.db.labels.search({
    data: { /* filters below */ },
    limit: 100,
    offset: 0,
});
```

### Searchable filters

| Field            | Type     | Operators                                  |
| ---------------- | -------- | ------------------------------------------ |
| `entity_id`      | `string` | equals, contains, startsWith, endsWith, in |
| `id`             | `string` | equals, contains, startsWith, endsWith, in |
| `name`           | `string` | equals, contains, startsWith, endsWith, in |
| `messagesTotal`  | `number` | equals, gt, gte, lt, lte, in               |
| `messagesUnread` | `number` | equals, gt, gte, lt, lte, in               |
| `threadsTotal`   | `number` | equals, gt, gte, lt, lte, in               |
| `threadsUnread`  | `number` | equals, gt, gte, lt, lte, in               |
| `createdAt`      | `date`   | equals, before, after, between             |

*Every `.search()` also accepts `limit` and `offset` for pagination. `.list()` is available on the same path without the `.search` suffix in code — see [database operations](/concepts/database).*

***

## Messages

Path: `gmail.db.messages.search`

```ts theme={null}
const rows = await corsair.gmail.db.messages.search({
    data: { /* filters below */ },
    limit: 100,
    offset: 0,
});
```

### Searchable filters

| Field          | Type     | Operators                                  |
| -------------- | -------- | ------------------------------------------ |
| `entity_id`    | `string` | equals, contains, startsWith, endsWith, in |
| `id`           | `string` | equals, contains, startsWith, endsWith, in |
| `threadId`     | `string` | equals, contains, startsWith, endsWith, in |
| `snippet`      | `string` | equals, contains, startsWith, endsWith, in |
| `historyId`    | `string` | equals, contains, startsWith, endsWith, in |
| `internalDate` | `string` | equals, contains, startsWith, endsWith, in |
| `sizeEstimate` | `number` | equals, gt, gte, lt, lte, in               |
| `raw`          | `string` | equals, contains, startsWith, endsWith, in |
| `subject`      | `string` | equals, contains, startsWith, endsWith, in |
| `body`         | `string` | equals, contains, startsWith, endsWith, in |
| `from`         | `string` | equals, contains, startsWith, endsWith, in |
| `to`           | `string` | equals, contains, startsWith, endsWith, in |
| `createdAt`    | `date`   | equals, before, after, between             |

*Every `.search()` also accepts `limit` and `offset` for pagination. `.list()` is available on the same path without the `.search` suffix in code — see [database operations](/concepts/database).*

***

## Threads

Path: `gmail.db.threads.search`

```ts theme={null}
const rows = await corsair.gmail.db.threads.search({
    data: { /* filters below */ },
    limit: 100,
    offset: 0,
});
```

### Searchable filters

| Field       | Type     | Operators                                  |
| ----------- | -------- | ------------------------------------------ |
| `entity_id` | `string` | equals, contains, startsWith, endsWith, in |
| `id`        | `string` | equals, contains, startsWith, endsWith, in |
| `snippet`   | `string` | equals, contains, startsWith, endsWith, in |
| `historyId` | `string` | equals, contains, startsWith, endsWith, in |
| `createdAt` | `date`   | equals, before, after, between             |

*Every `.search()` also accepts `limit` and `offset` for pagination. `.list()` is available on the same path without the `.search` suffix in code — see [database operations](/concepts/database).*

***
