Skip to main content
Version: v2

Finder

Enables navigating through the provided schema.

Methods​

(path: string) => SubSchema[]

import { Finder } from 'dynamodb-toolbox/schema/actions/finder'

const pokemonSchema = item({
evolutions: list(map({ level: number() })).savedAs('_e'),
...
})

const finder = pokemonSchema.build(Finder)
const subschemas = finder.search('evolutions[1].level')

const [levelSubSchema] = subschemas
info

The path formalism is the same as within Conditions and Projections.

The .search() method may return an empty array if no subschema is found for the provided path. It may also return several subschemas if several options of an anyOf attribute match the provided path.

SubSchemas​

Subschemas are Schema Actions that also contain a path:

const levelSchema = levelSubSchema.schema
// => number()

const formattedPath = levelSubSchema.formattedPath
const originalStrPath = formattedPath.strPath
// => 'evolutions[1].level'
const originalArrPath = formattedPath.arrayPath
// => ['evolutions', 1, 'level']

const transformedPath = levelSubSchema.transformedPath
const transformedStrPath = transformedPath.strPath
// => '_e[1].level'
const transformedArrPath = transformedPath.arrayPath
// => ['_e', 1, 'level']