Skip to content
Source
Sign inSign up
TanStack/db

Virtual props implementation #1213

Mergedsamwillis(GitHub profile, opens in a new tab)merged 97 commits intomain fromrefs/pull/1213/headmerged by samwillis(GitHub profile, opens in a new tab)

Showing 76 changed files with 26 additions and 10 deletions (loading 72).

x
0 of 76 viewed, 76 left
6 additions and 0 deletions.changeset/shiny-planes-laugh.mdAdded
View file
@@ -0,0 +1,6 @@
+---
+'@tanstack/db': patch
+---
+​
+Implement virtual properties end-to-end, including live query behavior and
+typing support for virtual metadata on rows.
12 additions and 0 deletionsdocs/guides/live-queries.mdModified
View file
@@ -29,6 +29,18 @@
​
The result types are automatically inferred from your query structure, providing full TypeScript support. When you use a `select` clause, the result type matches your projection. Without `select`, you get the full schema with proper join optionality.
​
+## Virtual properties
+​
+Live query results include computed, read-only virtual properties on every row:
+​
+- `$synced`: `true` when the row is confirmed by sync; `false` when it is still optimistic.
+- `$origin`: `"local"` if the last confirmed change came from this client, otherwise `"remote"`.
+- `$key`: the row key for the result.
+- `$collectionId`: the source collection ID.
+​
+These props can be used in `where`, `select`, and `orderBy` clauses. They are added to
+query outputs automatically and should not be persisted back to storage.
+​