pluck
constpluck: {<A,I,K>(key): <R>(schema) =>SchemaClass<A[K], { [K in string | number | symbol]: Pick<I, K>[K] },R>; <A,I,R,K>(schema,key):SchemaClass<A[K], { [K in string | number | symbol]: Pick<I, K>[K] },R>; }
Defined in: node_modules/.pnpm/effect@3.15.2/node_modules/effect/dist/dts/Schema.d.ts:1497
Given a schema Schema<A, I, R> and a key key: K, this function extracts a specific field from the A type,
producing a new schema that represents a transformation from the { readonly [key]: I[K] } type to A[K].
Call Signature
Section titled “Call Signature”<
A,I,K>(key): <R>(schema) =>SchemaClass<A[K], { [K in string | number | symbol]: Pick<I, K>[K] },R>
Given a schema Schema<A, I, R> and a key key: K, this function extracts a specific field from the A type,
producing a new schema that represents a transformation from the { readonly [key]: I[K] } type to A[K].
Type Parameters
Section titled “Type Parameters”A
I
K extends string | number | symbol
Parameters
Section titled “Parameters”K
Returns
Section titled “Returns”<
R>(schema):SchemaClass<A[K], { [K in string | number | symbol]: Pick<I, K>[K] },R>
Type Parameters
Section titled “Type Parameters”R
Parameters
Section titled “Parameters”schema
Section titled “schema”Schema<A, I, R>
Returns
Section titled “Returns”SchemaClass<A[K], { [K in string | number | symbol]: Pick<I, K>[K] }, R>
Example
Section titled “Example”import * as Schema from "effect/Schema"
// ---------------------------------------------// use case: pull out a single field from a// struct through a transformation// ---------------------------------------------
const mytable = Schema.Struct({ column1: Schema.NumberFromString, column2: Schema.Number})
// const pullOutColumn: S.Schema<number, {// readonly column1: string;// }, never>const pullOutColumn = mytable.pipe(Schema.pluck("column1"))
console.log(Schema.decodeUnknownEither(Schema.Array(pullOutColumn))([{ column1: "1", column2: 100 }, { column1: "2", column2: 300 }]))// Output: { _id: 'Either', _tag: 'Right', right: [ 1, 2 ] }3.10.0
Call Signature
Section titled “Call Signature”<
A,I,R,K>(schema,key):SchemaClass<A[K], { [K in string | number | symbol]: Pick<I, K>[K] },R>
Given a schema Schema<A, I, R> and a key key: K, this function extracts a specific field from the A type,
producing a new schema that represents a transformation from the { readonly [key]: I[K] } type to A[K].
Type Parameters
Section titled “Type Parameters”A
I
R
K extends string | number | symbol
Parameters
Section titled “Parameters”schema
Section titled “schema”Schema<A, I, R>
K
Returns
Section titled “Returns”SchemaClass<A[K], { [K in string | number | symbol]: Pick<I, K>[K] }, R>
Example
Section titled “Example”import * as Schema from "effect/Schema"
// ---------------------------------------------// use case: pull out a single field from a// struct through a transformation// ---------------------------------------------
const mytable = Schema.Struct({ column1: Schema.NumberFromString, column2: Schema.Number})
// const pullOutColumn: S.Schema<number, {// readonly column1: string;// }, never>const pullOutColumn = mytable.pipe(Schema.pluck("column1"))
console.log(Schema.decodeUnknownEither(Schema.Array(pullOutColumn))([{ column1: "1", column2: 100 }, { column1: "2", column2: 300 }]))// Output: { _id: 'Either', _tag: 'Right', right: [ 1, 2 ] }3.10.0
Example
Section titled “Example”import * as Schema from "effect/Schema"
// ---------------------------------------------// use case: pull out a single field from a// struct through a transformation// ---------------------------------------------
const mytable = Schema.Struct({ column1: Schema.NumberFromString, column2: Schema.Number})
// const pullOutColumn: S.Schema<number, {// readonly column1: string;// }, never>const pullOutColumn = mytable.pipe(Schema.pluck("column1"))
console.log(Schema.decodeUnknownEither(Schema.Array(pullOutColumn))([{ column1: "1", column2: 100 }, { column1: "2", column2: 300 }]))// Output: { _id: 'Either', _tag: 'Right', right: [ 1, 2 ] }3.10.0