---
title: Filter
description: Filter protocol schemas
---

{/* ⚠️  AUTO-GENERATED — DO NOT EDIT. Run build-docs.ts to regenerate. Hand-written docs go in content/docs/guides/. */}

Unified Query DSL Specification

Based on industry best practices from:

- Prisma ORM

- Strapi CMS

- TypeORM

- LoopBack Framework

Version: 1.0.0

Status: Draft

Objective: Define a JSON-based, database-agnostic query syntax standard

for data filtering interactions between frontend and backend APIs.

Design Principles:

1. Declarative: Frontend describes "what data to get", not "how to query"

2. Database Agnostic: Syntax contains no database-specific directives

3. Type Safe: Structure can be statically inferred by TypeScript

4. Convention over Configuration: Implicit syntax for common queries

<Callout type="info">
**Source:** `packages/spec/src/data/filter.zod.ts`
</Callout>

## TypeScript Usage

```typescript
import { EqualityOperator, FieldReference, FilterCondition, QueryFilter, SetOperator, SpecialOperator, StringOperator } from '@objectstack/spec/data';
import type { EqualityOperator, FieldReference, FilterCondition, QueryFilter, SetOperator, SpecialOperator, StringOperator } from '@objectstack/spec/data';

// Validate data
const result = EqualityOperator.parse(data);
```

---

## EqualityOperator

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **$eq** | `any` | optional |  |
| **$ne** | `any` | optional |  |


---

## FieldReference

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **$field** | `string` | ✅ | Field Reference/Column Name |


---


---

## QueryFilter

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **where** | `[__schema0](./__schema0)` | optional |  |


---

## SetOperator

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **$in** | `any[]` | optional |  |
| **$nin** | `any[]` | optional |  |


---

## SpecialOperator

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **$null** | `boolean` | optional |  |
| **$exists** | `boolean` | optional |  |


---

## StringOperator

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **$contains** | `string` | optional |  |
| **$notContains** | `string` | optional |  |
| **$startsWith** | `string` | optional |  |
| **$endsWith** | `string` | optional |  |


---

