---
title: Array Filters
description: Filter operators for array scalars
icon: list-ordered
---

Array scalars (`s.string().array()`, `s.int().array()`, etc.) work identically on every database.

## Operators

| Operator | Description |
|----------|-------------|
| `has` | Array contains value |
| `hasEvery` | Array contains all values |
| `hasSome` | Array contains any value |
| `isEmpty` | Array is empty |
| `equals` | Exact array match (order matters) |

## has

Check if array contains a single value:

```ts
// Has "featured" tag
where: {
  tags: { has: "featured" },
}

// Has specific role
where: {
  roles: { has: "ADMIN" },
}
```

`has: null` never matches any row (SQL `NULL = element` is never true), matching Prisma semantics.

## hasEvery

Check if array contains ALL specified values:

```ts
// Has both "tech" and "tutorial"
where: {
  tags: { hasEvery: ["tech", "tutorial"] },
}

// User has all required permissions
where: {
  permissions: { hasEvery: ["read", "write", "delete"] },
}
```

## hasSome

Check if array contains ANY of the specified values:

```ts
// Has "tech" OR "science" OR "programming"
where: {
  tags: { hasSome: ["tech", "science", "programming"] },
}

// User has at least one admin permission
where: {
  permissions: { hasSome: ["admin", "superuser"] },
}
```

## isEmpty

Check if array is empty:

```ts
// No tags
where: {
  tags: { isEmpty: true },
}

// Has at least one tag
where: {
  tags: { isEmpty: false },
}
```

## Updating Arrays

```ts
// Add to array
await client.post.update({
  where: { id: "post_123" },
  data: {
    tags: { push: "new-tag" },
  },
});

// Add several values (each appended as its own element)
await client.post.update({
  where: { id: "post_123" },
  data: {
    tags: { push: ["tag-a", "tag-b"] },
  },
});

// Prepend instead of append
await client.post.update({
  where: { id: "post_123" },
  data: {
    tags: { unshift: "first-tag" },
  },
});

// Set entire array
await client.post.update({
  where: { id: "post_123" },
  data: {
    tags: { set: ["tag1", "tag2", "tag3"] },
  },
});
```

## JSON Columns as an Alternative

If you need more flexibility than the array operators above (e.g. arrays of objects, or ad hoc JSON structures), you can still model a field as raw JSON and use the [JSON filter operators](/docs/client/filtering/json) instead:

```ts
// Schema
const post = s.model({
  id: s.string().id(),
  metadata: s.json().default([]),
});

// Query with JSON operators (array_contains only matches array values)
where: {
  metadata: {
    array_contains: "featured",
  },
}
```
