Defined in: packages/db/src/virtual-props.ts:57
Virtual properties available on every row in TanStack DB collections.
These properties are:
// Accessing virtual properties on a row
const user = collection.get('user-1')
if (user.$synced) {
console.log('Confirmed by backend')
}
if (user.$origin === 'local') {
console.log('Created/modified locally')
}
// Using virtual properties in queries
const confirmedOrders = createLiveQueryCollection({
query: (q) => q
.from({ order: orders })
.where(({ order }) => eq(order.$synced, true))
})
TKey extends string | number = string | number
The type of the row's key (string or number)
readonly $collectionId: string;
Defined in: packages/db/src/virtual-props.ts:96
The ID of the source collection this row originated from.
In joins, this can help identify which collection each row came from. For live query collections, this is the ID of the upstream collection.
readonly $key: TKey;
Defined in: packages/db/src/virtual-props.ts:88
The row's key (primary identifier).
This is the same value returned by collection.config.getKey(row). Useful when you need the key in projections or computations.
readonly $origin: VirtualOrigin;
Defined in: packages/db/src/virtual-props.ts:80
Origin of the last confirmed change to this row, from the current client's perspective.
For local-only collections, this is always 'local'. For live query collections, this is passed through from the source collection.
readonly $synced: boolean;
Defined in: packages/db/src/virtual-props.ts:69
Whether this row reflects confirmed state from the backend.
For local-only collections (no sync), this is always true. For live query collections, this is passed through from the source collection.