MCPcopy Index your code
hub / github.com/TanStack/db / buildSubscriptionOptions

Method buildSubscriptionOptions

packages/db/src/query/effect.ts:797–826  ·  view source on GitHub ↗

* Build subscription options for an alias based on whether it uses ordered * loading, is lazy, or should pass orderBy/limit hints.

(
    alias: string,
    isLazy: boolean,
    orderByInfo: OrderByOptimizationInfo | undefined,
    whereExpression: BasicExpression<boolean> | undefined,
  )

Source from the content-addressed store, hash-verified

795 * loading, is lazy, or should pass orderBy/limit hints.
796 */
797 private buildSubscriptionOptions(
798 alias: string,
799 isLazy: boolean,
800 orderByInfo: OrderByOptimizationInfo | undefined,
801 whereExpression: BasicExpression<boolean> | undefined,
802 ): {
803 includeInitialState?: boolean
804 whereExpression?: BasicExpression<boolean>
805 orderBy?: any
806 limit?: number
807 } {
808 // Ordered aliases explicitly disable initial state — data is loaded
809 // via requestLimitedSnapshot/requestSnapshot after subscription setup.
810 if (orderByInfo) {
811 return { includeInitialState: false, whereExpression }
812 }
813
814 const includeInitialState = !isLazy
815
816 // For unordered subscriptions, pass orderBy/limit hints so on-demand
817 // collections can optimise server-side fetching.
818 const hints = computeSubscriptionOrderByHints(this.query, alias)
819
820 return {
821 includeInitialState,
822 whereExpression,
823 ...(hints.orderBy ? { orderBy: hints.orderBy } : {}),
824 ...(hints.limit !== undefined ? { limit: hints.limit } : {}),
825 }
826 }
827
828 /**
829 * Request the initial ordered snapshot for an alias.

Callers 1

startMethod · 0.95

Calls 1

Tested by

no test coverage detected