Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions docs/collections/trailbase-collection.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ const todosCollection = createCollection(
## Complete Example

```typescript
import { createCollection, eq } from '@tanstack/react-db'
import { createCollection } from '@tanstack/react-db'
import { not } from '@tanstack/db'
import { trailBaseCollectionOptions } from '@tanstack/trailbase-db-collection'
import { initClient } from 'trailbase'
import { z } from 'zod'
Expand Down Expand Up @@ -195,7 +196,7 @@ export const todosCollection = createCollection<SelectTodo, Todo>(
function TodoList() {
const { data: todos } = useLiveQuery((q) =>
q.from({ todo: todosCollection })
.where(({ todo }) => eq(todo.completed, false))
.where(({ todo }) => not(todo.completed))
.orderBy(({ todo }) => todo.created_at, 'desc')
)

Expand Down
8 changes: 4 additions & 4 deletions docs/guides/schemas.md
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,8 @@ A complete todo application demonstrating validation, transformations, and defau

```typescript
import { z } from 'zod'
import { createCollection, eq } from '@tanstack/react-db'
import { createCollection } from '@tanstack/react-db'
import { not } from '@tanstack/db'
import { queryCollectionOptions } from '@tanstack/query-db-collection'

// Schema with validation, transformations, and defaults
Expand Down Expand Up @@ -921,7 +922,7 @@ const todoCollection = createCollection(
function TodoApp() {
const { data: todos } = useLiveQuery(q =>
q.from({ todo: todoCollection })
.where(({ todo }) => eq(todo.completed, false))
.where(({ todo }) => not(todo.completed))
.orderBy(({ todo }) => todo.created_at, 'desc')
)

Expand Down Expand Up @@ -991,7 +992,6 @@ function TodoApp() {

```typescript
import { z } from 'zod'
import { eq } from '@tanstack/db'

// Schema with computed fields and transformations
const productSchema = z.object({
Expand Down Expand Up @@ -1047,7 +1047,7 @@ const productCollection = createCollection(
function ProductList() {
const { data: products } = useLiveQuery(q =>
q.from({ product: productCollection })
.where(({ product }) => eq(product.in_stock, true)) // Use computed field
.where(({ product }) => product.in_stock) // Use computed field
.orderBy(({ product }) => product.final_price, 'asc')
)

Expand Down
2 changes: 1 addition & 1 deletion docs/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const todoCollection = createCollection({
const Todos = () => {
// Bind data using live queries
const { data: todos } = useLiveQuery((q) =>
q.from({ todo: todoCollection }).where(({ todo }) => eq(todo.completed, false))
q.from({ todo: todoCollection }).where(({ todo }) => not(todo.completed))
)

const complete = (todo) => {
Expand Down
4 changes: 2 additions & 2 deletions docs/reference/classes/BaseQueryBuilder.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ A QueryBuilder with the specified source
query.from({ users: usersCollection })

// Query from a subquery
const activeUsers = query.from({ u: usersCollection }).where(({u}) => eq(u.active, true))
const activeUsers = query.from({ u: usersCollection }).where(({u}) => u.active)
query.from({ activeUsers })
```

Expand Down Expand Up @@ -550,7 +550,7 @@ query
```

// Join with a subquery
const activeUsers = query.from({ u: usersCollection }).where(({u}) => eq(u.active, true))
const activeUsers = query.from({ u: usersCollection }).where(({u}) => u.active)
query
.from({ activeUsers })
.join({ p: postsCollection }, ({u, p}) => eq(u.id, p.userId))
Expand Down
4 changes: 2 additions & 2 deletions packages/db/src/query/builder/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export class BaseQueryBuilder<TContext extends Context = Context> {
* query.from({ users: usersCollection })
*
* // Query from a subquery
* const activeUsers = query.from({ u: usersCollection }).where(({u}) => eq(u.active, true))
* const activeUsers = query.from({ u: usersCollection }).where(({u}) => u.active)
* query.from({ activeUsers })
* ```
*/
Expand Down Expand Up @@ -171,7 +171,7 @@ export class BaseQueryBuilder<TContext extends Context = Context> {
* ```
*
* // Join with a subquery
* const activeUsers = query.from({ u: usersCollection }).where(({u}) => eq(u.active, true))
* const activeUsers = query.from({ u: usersCollection }).where(({u}) => u.active)
* query
* .from({ activeUsers })
* .join({ p: postsCollection }, ({u, p}) => eq(u.id, p.userId))
Expand Down
Loading