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

Function createCollectionIndexMetadata

packages/db/src/collection/indexes.ts:156–185  ·  view source on GitHub ↗
(
  indexId: number,
  expression: BasicExpression,
  name: string | undefined,
  resolver: IndexConstructor<TKey>,
  options: unknown,
)

Source from the content-addressed store, hash-verified

154}
155
156function createCollectionIndexMetadata<TKey extends string | number>(
157 indexId: number,
158 expression: BasicExpression,
159 name: string | undefined,
160 resolver: IndexConstructor<TKey>,
161 options: unknown,
162): CollectionIndexMetadata {
163 const resolverMetadata = resolveResolverMetadata(resolver)
164 const serializedExpression = toSerializableIndexValue(expression) ?? null
165 const serializedOptions = toSerializableIndexValue(options)
166 const signatureInput = toSerializableIndexValue({
167 signatureVersion: INDEX_SIGNATURE_VERSION,
168 expression: serializedExpression,
169 options: serializedOptions ?? null,
170 })
171 const normalizedSignatureInput = signatureInput ?? null
172 const signature = stableStringifyCollectionIndexValue(
173 normalizedSignatureInput,
174 )
175
176 return {
177 signatureVersion: INDEX_SIGNATURE_VERSION,
178 signature,
179 indexId,
180 name,
181 expression,
182 resolver: resolverMetadata,
183 ...(serializedOptions === undefined ? {} : { options: serializedOptions }),
184 }
185}
186
187function cloneSerializableIndexValue(
188 value: CollectionIndexSerializableValue,

Callers 1

createIndexMethod · 0.85

Calls 3

resolveResolverMetadataFunction · 0.85
toSerializableIndexValueFunction · 0.85

Tested by

no test coverage detected