How to use the types function from pg

Find comprehensive JavaScript pg.types code examples handpicked from public code repositorys.

67
68
69
70
71
72
73
74
75
76
77
loadTypeParser()


function loadTypeParser () {
  // https://github.com/tgriesser/knex/issues/387
  // converts PostgreSQL `bigint` into Javascript integers
  pg.types.setTypeParser(20, 'text', (value) => {
    if (Number.MAX_SAFE_INTEGER < value) {
      throw new Error(`The value ${value} exceeds the JS max integer value ${Number.MAX_SAFE_INTEGER}`)
    }

fork icon0
star icon0
watch icon0