# Transformers | @supabase/supabase-js
Documentation for @supabase/supabase-js

## Index

### Enumerations

- PostgresTypes

### Functions

- convertCell
- convertChangeData
- convertColumn
- toArray
- toBoolean
- toJson
- toNumber
- toTimestampString

## Functions

### convertCell

- convertCell(type: string, value: RecordValue): RecordValue

- - Defined in node_modules/@supabase/realtime-js/dist/module/lib/transformers.d.ts:84

  If the value of the cell is `null`, returns null. Otherwise converts the string value to the correct type.

  example

    convertCell('bool', 't') //=> true

  example

    convertCell('int8', '10') //=> 10

  example

    convertCell('_int4', '{1,2,3,4}') //=> [1,2,3,4]

  #### Parameters

  - ##### type: string

    A postgres column type

  - ##### value: RecordValue

  #### Returns RecordValue

### convertChangeData

- convertChangeData(columns: Columns, record: Record, options?: { skipTypes?: string[] }): Record

- - Defined in node_modules/@supabase/realtime-js/dist/module/lib/transformers.d.ts:53

  Takes an array of columns and an object of string values then converts each string value to its mapped type.

  example

    convertChangeData([{name: 'first_name', type: 'text'}, {name: 'age', type: 'int4'}], {first_name: 'Paul', age:'33'}, {}) //=>{ first_name: 'Paul', age: 33 }

  #### Parameters

  - ##### columns: Columns

  - ##### record: Record

  - ##### Optional options: { skipTypes?: string[] }

    The map of various options that can be applied to the mapper

    - ##### Optional skipTypes?: string[]

      The array of types that should not be converted

  #### Returns Record

### convertColumn

- convertColumn(columnName: string, columns: Columns, record: Record, skipTypes: string[]): RecordValue

- - Defined in node_modules/@supabase/realtime-js/dist/module/lib/transformers.d.ts:70

  Converts the value of an individual column.

  example

    convertColumn('age', [{name: 'first_name', type: 'text'}, {name: 'age', type: 'int4'}], {first_name: 'Paul', age: '33'}, []) //=> 33

  example

    convertColumn('age', [{name: 'first_name', type: 'text'}, {name: 'age', type: 'int4'}], {first_name: 'Paul', age: '33'}, ['int4']) //=> "33"

  #### Parameters

  - ##### columnName: string

    The column that you want to convert

  - ##### columns: Columns

  - ##### record: Record

    The map of string values

  - ##### skipTypes: string[]

    An array of types that should not be converted

  #### Returns RecordValue

  Useless information

### toArray

- toArray(value: RecordValue, type: string): RecordValue

- - Defined in node_modules/@supabase/realtime-js/dist/module/lib/transformers.d.ts:98

  Converts a Postgres Array into a native JS array

  example

    toArray('{}', 'int4') //=> []

  example

    toArray('{"[2021-01-01,2021-12-31)","(2021-01-01,2021-12-32]"}', 'daterange') //=> ['[2021-01-01,2021-12-31)', '(2021-01-01,2021-12-32]']

  example

    toArray([1,2,3,4], 'int4') //=> [1,2,3,4]

  #### Parameters

  - ##### value: RecordValue

  - ##### type: string

  #### Returns RecordValue

### toBoolean

- toBoolean(value: RecordValue): RecordValue

- - Defined in node_modules/@supabase/realtime-js/dist/module/lib/transformers.d.ts:85

  #### Parameters

  - ##### value: RecordValue

  #### Returns RecordValue

### toJson

- toJson(value: RecordValue): RecordValue

- - Defined in node_modules/@supabase/realtime-js/dist/module/lib/transformers.d.ts:87

  #### Parameters

  - ##### value: RecordValue

  #### Returns RecordValue

### toNumber

- toNumber(value: RecordValue): RecordValue

- - Defined in node_modules/@supabase/realtime-js/dist/module/lib/transformers.d.ts:86

  #### Parameters

  - ##### value: RecordValue

  #### Returns RecordValue

### toTimestampString

- toTimestampString(value: RecordValue): RecordValue

- - Defined in node_modules/@supabase/realtime-js/dist/module/lib/transformers.d.ts:106

  Fixes timestamp to be ISO-8601. Swaps the space between the date and time for a 'T' See https://github.com/supabase/supabase/issues/18

  example

    toTimestampString('2019-09-10 00:00:00') //=> '2019-09-10T00:00:00'

  #### Parameters

  - ##### value: RecordValue

  #### Returns RecordValue

Generated using TypeDoc