🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more →
Socket
Book a DemoInstallSign in
Socket

slonik-interceptor-json-rows

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

slonik-interceptor-json-rows

Slonik Json Interceptor

latest
npmnpm
Version
1.0.0
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

test workflow

Slonik Json Interceptor

Transform slonik's QueryResultRow key into json-ready objects.

API usage

import { createPool } from 'slonik';

import JsonInterceptor from 'slonik-json-row-interceptor';

const pool = createPool(connectionString, {
  interceptors: [JsonInterceptor]
});

pool.connect(async (connection) => {
  const query = sql`select
    u.id,
    u.name,
    c.id as "cars.id",
    c.name as "cars.name"
  from
    users u
      join cars c
      on u.id = c.owner;`;

  const results = await connection.many(query);
  console.log(results); // [ { id: 1, name: 'Foo', cars: { id: 1, name: 'Bar' } } ]
});

Keywords

postgresql

FAQs

Package last updated on 27 May 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts