---
title: EntityQuery
framework: realitykit
role: symbol
role_heading: Structure
path: realitykit/entityquery
---

# EntityQuery

An object that retrieves entities from a scene.

## Declaration

```swift
struct EntityQuery
```

## Mentioned in

Implementing systems for entities in a scene Implementing scene understanding and reconstruction in your RealityKit app

## Overview

Overview Use entity queries to iterate through all entities in a RealityKit scene that meet certain criteria. To specify which entities to retrieve, use a QueryPredicate. To execute the query, pass it into the scene’s performQuery(_:) method and then iterate over the results. // Build a query to retrieve all anchor components. let query = EntityQuery(where: .has(AnchorComponent.self))

// Find and modify the scene's entities that have an anchor component. scene.performQuery(query).forEach { entity in     // Make any needed changes to entities. }

## Topics

### Creating an entity query

- [init()](realitykit/entityquery/init().md)
- [init(where:)](realitykit/entityquery/init(where:).md)

## Relationships

### Conforms To

- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Entity queries

- [QueryPredicate](realitykit/querypredicate.md)
- [QueryResult](realitykit/queryresult.md)
