Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace Transformers

Index

Functions

  • convertCell(type: string, value: RecordValue): RecordValue
  • 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(columns: Columns, record: Record, options?: { skipTypes?: string[] }): Record
  • 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(columnName: string, columns: Columns, record: Record, skipTypes: string[]): RecordValue
  • 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(value: RecordValue, type: string): RecordValue
  • 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(value: RecordValue): RecordValue
  • Parameters

    • value: RecordValue

    Returns RecordValue

  • toJson(value: RecordValue): RecordValue
  • Parameters

    • value: RecordValue

    Returns RecordValue

  • toNumber(value: RecordValue): RecordValue
  • Parameters

    • value: RecordValue

    Returns RecordValue

  • toTimestampString(value: RecordValue): RecordValue
  • 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