@@ -9,8 +9,12 @@ import {
99} from "../types/pocketbase-api-response.type" ;
1010import type { PocketBaseEntry } from "../types/pocketbase-entry.type" ;
1111import type { ExperimentalPocketBaseLiveLoaderCollectionFilter } from "../types/pocketbase-live-loader-filter.type" ;
12- import type { PocketBaseLoaderBaseOptions } from "../types/pocketbase-loader-options.type" ;
12+ import type {
13+ ExperimentalPocketBaseLiveLoaderOptions ,
14+ PocketBaseLoaderOptions
15+ } from "../types/pocketbase-loader-options.type" ;
1316import { combineFieldsForRequest } from "../utils/combine-fields-for-request" ;
17+ import { formatExpand } from "../utils/format-expand" ;
1418import { formatFields } from "../utils/format-fields" ;
1519
1620/**
@@ -28,7 +32,7 @@ export type CollectionFilter = {
2832 * Fetches entries from a PocketBase collection, optionally filtering by modification date and supporting pagination.
2933 */
3034export async function fetchCollection < TEntry extends PocketBaseEntry > (
31- options : PocketBaseLoaderBaseOptions ,
35+ options : PocketBaseLoaderOptions | ExperimentalPocketBaseLiveLoaderOptions ,
3236 chunkLoaded : ( entries : Array < TEntry > ) => Promise < void > ,
3337 token : string | undefined ,
3438 collectionFilter : CollectionFilter | undefined
@@ -124,7 +128,9 @@ export async function fetchCollection<TEntry extends PocketBaseEntry>(
124128 * Build search parameters for the PocketBase collection request.
125129 */
126130function buildSearchParams (
127- loaderOptions : PocketBaseLoaderBaseOptions ,
131+ loaderOptions :
132+ | PocketBaseLoaderOptions
133+ | ExperimentalPocketBaseLiveLoaderOptions ,
128134 combinedFields : Array < string > | undefined ,
129135 collectionFilter : CollectionFilter
130136) : URLSearchParams {
@@ -173,5 +179,15 @@ function buildSearchParams(
173179 searchParams . set ( "fields" , combinedFields . join ( "," ) ) ;
174180 }
175181
182+ if ( loaderOptions . experimental && "expand" in loaderOptions . experimental ) {
183+ const expandString = formatExpand (
184+ loaderOptions . experimental . expand ,
185+ loaderOptions . collectionName
186+ ) ;
187+ if ( expandString ) {
188+ searchParams . set ( "expand" , expandString ) ;
189+ }
190+ }
191+
176192 return searchParams ;
177193}
0 commit comments