pg-tuple-types

0.0.1 • Public • Published

pg-tuple-types

Add node-postgres support for:

  • composite tuples
  • arrays of tuples

Installing

$ yarn add pg-tuple-types

Usage

import pg from 'pg'
import { initTypes } from 'pg-tuple-types'

const { Client } = pg

const sql = new Client()

sql.connect()

;(async () => {
    // load types definitions from DB schema
    await initTypes(pg.types)(sql)

    const customer = await sql.query(`select
            customer._c,
            array_agg(cart)
        from
            (
                select
                customer _c
                from
                customer
                limit 2) customer
        join cart on
            (cart.customer_id = (customer._c).id)
        group by
            customer._c`)

    console.log(JSON.stringify(customer.rows, null, ' '))
})().finally(() => sql.end())

License

Copyright © 2022 Fabiano Taioli; Released under the MIT license.

Readme

Keywords

none

Package Sidebar

Install

npm i pg-tuple-types

Weekly Downloads

0

Version

0.0.1

License

MIT

Unpacked Size

534 kB

Total Files

9

Last publish

Collaborators

  • fbn79