Query Structure
A query consists of three fields:find, match, and an optional where filter.
find
The find field is an array of component name strings (the value returned by Component.Name()). At least one component is required, and unregistered component names will cause an error. You can include tag components to narrow results.
match
The match field controls how components are matched:
| Value | Description |
|---|---|
"exact" | Finds entities that have exactly the specified components, nothing more |
"contains" | Finds entities that have at least the specified components, but may have others |
where
The where field is an optional expr-lang expression that filters entities. The expression is evaluated per entity and must return a boolean. Access components by name and fields by dot notation. The entity ID is available as _id.
Examples:
- Comparisons:
health.HP > 100 - Logic:
playertag.Level >= 10 && health.HP > 50 - String Operations:
playertag.Nickname contains "admin"
==, !=, >, <, >=, <=, &&, and ||.
Sending Queries
Use the client SDK to query entities from the server:- Unity C#
- TypeScript
entities array. Each entity includes _id (the entity ID) and one property per component, keyed by component name: