liveQueryCollectionOptions

Funktion: liveQueryCollectionOptions()

ts
function liveQueryCollectionOptions<TContext, TResult>(config): CollectionConfig<TResult>
function liveQueryCollectionOptions<TContext, TResult>(config): CollectionConfig<TResult>

Definiert in: packages/db/src/query/live-query-collection.ts:117

Erstellt Live-Query-Sammlungsoptionen zur Verwendung mit createCollection

Typparameter

TContext erweitert Context

TResult erweitert object = { [K in string | number | symbol]: (TContext["result"] extends object ? any[any] : TContext["hasJoins"] extends true ? TContext["schema"] : TContext["schema"][TContext["fromSourceName"]])[K] }

Parameter

config

LiveQueryCollectionConfig<TContext, TResult>

Konfigurationsoptionen für die Live-Query-Sammlung

Gibt zurück

CollectionConfig<TResult>

Sammlungsoptionen, die an createCollection übergeben werden können

Beispiel

typescript
const options = liveQueryCollectionOptions({
  // id is optional - will auto-generate if not provided
  query: (q) => q
    .from({ post: postsCollection })
    .where(({ post }) => eq(post.published, true))
    .select(({ post }) => ({
      id: post.id,
      title: post.title,
      content: post.content,
    })),
  // getKey is optional - will use stream key if not provided
})

const collection = createCollection(options)
const options = liveQueryCollectionOptions({
  // id is optional - will auto-generate if not provided
  query: (q) => q
    .from({ post: postsCollection })
    .where(({ post }) => eq(post.published, true))
    .select(({ post }) => ({
      id: post.id,
      title: post.title,
      content: post.content,
    })),
  // getKey is optional - will use stream key if not provided
})

const collection = createCollection(options)
Unsere Partner
Code Rabbit
Electric
Prisma
Bytes abonnieren

Ihre wöchentliche Dosis JavaScript-Nachrichten. Jeden Montag kostenlos an über 100.000 Entwickler geliefert.

Bytes

Kein Spam. Jederzeit kündbar.

Bytes abonnieren

Ihre wöchentliche Dosis JavaScript-Nachrichten. Jeden Montag kostenlos an über 100.000 Entwickler geliefert.

Bytes

Kein Spam. Jederzeit kündbar.