You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Relations can be queried with specific targets, wildcard targets using `*` and even inverted wildcard searches with `Wildcard` to get all entities with a relation targeting another entity.
210
+
Relations can be queried with specific targets and wildcard targets using `*`.
Relations work with tracking modifiers to detect when entities gain, lose, or update relations. Changes can only be tracked on relations that have a store.
257
+
258
+
> 👉 **Note**<br>
259
+
> You can currently only track changes to all relations of a given type, such as `ChildOf`, but not specific relation pairs, such as `ChildOf(parent)`.
The `Added` modifier tracks all entities that have added the specified traits since the last time the query was run. A new instance of the modifier must be created for tracking to be unique.
315
+
The `Added` modifier tracks all entities that have added the specified traits or relations since the last time the query was run. A new instance of the modifier must be created for tracking to be unique.
283
316
284
317
```js
285
318
import { createAdded } from'koota'
286
319
287
320
constAdded=createAdded()
288
321
289
-
//This query will return entities that have just added the Position trait
322
+
//Track entities that added the Position trait
290
323
constnewPositions=world.query(Added(Position))
291
324
325
+
// Track entities that added a ChildOf relation
326
+
constnewChildren=world.query(Added(ChildOf))
327
+
292
328
// After running the query, the Added modifier is reset
293
329
```
294
330
295
331
#### Removed
296
332
297
-
The `Removed` modifier tracks all entities that have removed the specified traits since the last time the query was run. This includes entities that have been destroyed. A new instance of the modifier must be created for tracking to be unique.
333
+
The `Removed` modifier tracks all entities that have removed the specified traits or relations since the last time the query was run. This includes entities that have been destroyed. A new instance of the modifier must be created for tracking to be unique.
298
334
299
335
```js
300
336
import { createRemoved } from'koota'
301
337
302
338
constRemoved=createRemoved()
303
339
304
-
//This query will return entities that have just removed the Velocity trait
// After running the query, the Removed modifier is reset
308
347
```
309
348
310
349
#### Changed
311
350
312
-
The `Changed` modifier tracks all entities that have had the specified traits values change since the last time the query was run. A new instance of the modifier must be created for tracking to be unique.
351
+
The `Changed` modifier tracks all entities that have had the specified traits or relation stores change since the last time the query was run. A new instance of the modifier must be created for tracking to be unique.
313
352
314
353
```js
315
354
import { createChanged } from'koota'
316
355
317
356
constChanged=createChanged()
318
357
319
-
//This query will return entities whose Position has changed
358
+
//Track entities whose Position has changed
320
359
constmovedEntities=world.query(Changed(Position))
321
360
361
+
// Track entities whose ChildOf relation data has changed
0 commit comments