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

Function serializeLoadSubsetOptions

packages/query-db-collection/src/serialization.ts:9–54  ·  view source on GitHub ↗
(
  options: LoadSubsetOptions | undefined,
)

Source from the content-addressed store, hash-verified

7 * @internal
8 */
9export function serializeLoadSubsetOptions(
10 options: LoadSubsetOptions | undefined,
11): string | undefined {
12 if (!options) {
13 return undefined
14 }
15
16 const result: Record<string, unknown> = {}
17
18 if (options.where) {
19 result.where = serializeExpression(options.where)
20 }
21
22 if (options.orderBy?.length) {
23 result.orderBy = options.orderBy.map((clause) => {
24 const baseOrderBy = {
25 expression: serializeExpression(clause.expression),
26 direction: clause.compareOptions.direction,
27 nulls: clause.compareOptions.nulls,
28 stringSort: clause.compareOptions.stringSort,
29 }
30
31 // Handle locale-specific options when stringSort is 'locale'
32 if (clause.compareOptions.stringSort === `locale`) {
33 return {
34 ...baseOrderBy,
35 locale: clause.compareOptions.locale,
36 localeOptions: clause.compareOptions.localeOptions,
37 }
38 }
39
40 return baseOrderBy
41 })
42 }
43
44 if (options.limit !== undefined) {
45 result.limit = options.limit
46 }
47
48 // Include offset for pagination support
49 if (options.offset !== undefined) {
50 result.offset = options.offset
51 }
52
53 return Object.keys(result).length === 0 ? undefined : JSON.stringify(result)
54}
55
56/**
57 * Recursively serializes an IR expression for stable hashing

Callers 1

Calls 3

serializeExpressionFunction · 0.70
mapMethod · 0.45
keysMethod · 0.45

Tested by

no test coverage detected