# Predicates

Build type-safe query conditions with the predicate DSL in the SurrealDB Swift SDK.

Predicates are type-safe conditions used to filter records in [`select`](/docs/reference/swift/methods/select.md), [`update`](/docs/reference/swift/methods/update.md), [`upsert`](/docs/reference/swift/methods/upsert.md) and [`delete`](/docs/reference/swift/methods/delete.md). They are built from the `Fields` namespace generated by the [`@SurrealModel` macro](/docs/reference/swift/concepts/models.md).

## Comparison operators

Each field supports the standard comparison operators:

```swift
Person.Fields.name == "Ada"
Person.Fields.name != "Bob"
Person.Fields.age > 18
Person.Fields.age >= 21
Person.Fields.age < 65
Person.Fields.age <= 60
```

## Combining predicates

Combine predicates with the logical operators `&&`, `||` and `!`:

```swift
let combined = Person.Fields.age >= 18 && Person.Fields.published == true
let either = Person.Fields.age < 18 || Person.Fields.name == "Admin"
let negated = !(Person.Fields.published == false)
```

## Raw predicates

When you need an expression that the DSL does not cover, or when using a [manually conformed model](/docs/reference/swift/concepts/models.md#manual-conformance) without a `Fields` namespace, you can supply a raw SurrealQL condition:

```swift
let raw = SurrealPredicate(raw: "age > 18 AND name != 'Bot'")
```

## Using a predicate

Pass a predicate to any method that accepts a `where:` argument:

```swift
let adults = try await client.select(
    Person.self,
    where: Person.Fields.age >= 18,
    limit: 20,
    start: 0
)
```
