diff --git a/docs/collections/trailbase-collection.md b/docs/collections/trailbase-collection.md index b5d6091bc..938e714a5 100644 --- a/docs/collections/trailbase-collection.md +++ b/docs/collections/trailbase-collection.md @@ -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' @@ -195,7 +196,7 @@ export const todosCollection = createCollection( 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') ) diff --git a/docs/guides/schemas.md b/docs/guides/schemas.md index f028e5dfe..4f453d45f 100644 --- a/docs/guides/schemas.md +++ b/docs/guides/schemas.md @@ -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 @@ -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') ) @@ -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({ @@ -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') ) diff --git a/docs/overview.md b/docs/overview.md index cb513ff11..a3111d561 100644 --- a/docs/overview.md +++ b/docs/overview.md @@ -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) => { diff --git a/docs/reference/classes/BaseQueryBuilder.md b/docs/reference/classes/BaseQueryBuilder.md index 550796b25..0962768ed 100644 --- a/docs/reference/classes/BaseQueryBuilder.md +++ b/docs/reference/classes/BaseQueryBuilder.md @@ -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 }) ``` @@ -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)) diff --git a/packages/db/src/query/builder/index.ts b/packages/db/src/query/builder/index.ts index c58ebc087..c43f3ad48 100644 --- a/packages/db/src/query/builder/index.ts +++ b/packages/db/src/query/builder/index.ts @@ -129,7 +129,7 @@ export class BaseQueryBuilder { * 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 }) * ``` */ @@ -171,7 +171,7 @@ export class BaseQueryBuilder { * ``` * * // 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))