# slonik-interceptor-field-name-transformation

> Transforms Slonik query result field names.

Latest version **49.10.10** (published 2026-09-21) · BSD-3-Clause license · 0 weekly downloads

## Install

```sh
npm install slonik-interceptor-field-name-transformation
pnpm add slonik-interceptor-field-name-transformation
yarn add slonik-interceptor-field-name-transformation
bun add slonik-interceptor-field-name-transformation
```

## Health

**Score 55/100 (C)** — status: active.

Positive: no vulnerabilities; recently updated; high maintenance score.

Warnings: low downloads; no types; no esm support.

## Facts

| | |
|---|---|
| Version | 49.10.10 |
| Published | 2026-09-21 |
| First published | 2019-02-22 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4938 |
| Author | Gajus Kuizinas |
| Maintainers | gajus |
| Keywords | format, interceptor, postgresql |

## Links

- npm: https://www.npmjs.com/package/slonik-interceptor-field-name-transformation
- Repository: https://github.com/gajus/slonik
- Homepage: https://github.com/gajus/slonik#readme
- Issues: https://github.com/gajus/slonik/issues
- npm.io page: https://npm.io/package/slonik-interceptor-field-name-transformation

## Alternatives

- [@libsql/sqlite3](https://npm.io/package/@libsql/sqlite3.md) — 39.8K weekly downloads
- [@fortemi/core](https://npm.io/package/@fortemi/core.md) — 461 weekly downloads
- [cdb-converter](https://npm.io/package/cdb-converter.md) — 341 weekly downloads
- [@uplo/adapter-prisma](https://npm.io/package/@uplo/adapter-prisma.md) — 75 weekly downloads
- [typeorm-aios](https://npm.io/package/typeorm-aios.md) — 30 weekly downloads

## Recent versions

- 49.10.10 (latest) — 2026-09-21
- 49.10.9 — 2026-07-26
- 49.10.8 — 2026-07-26
- 49.10.7 — 2026-06-16
- 49.10.6 — 2026-06-16
- 49.10.5 — 2026-06-16
- 49.10.4 — 2026-06-16
- 49.10.3 — 2026-06-16
- 49.10.1 — 2026-06-10
- 49.10.0 — 2026-06-05
- 49.9.0 — 2026-06-03
- 49.8.0 — 2026-05-29
- 49.7.0 — 2026-05-28
- 49.6.0 — 2026-05-28
- 49.5.0 — 2026-05-27
- … 112 more at https://npm.io/package/slonik-interceptor-field-name-transformation/versions

## README

# slonik-interceptor-field-name-transformation

[![NPM version](https://img.shields.io/npm/v/slonik-interceptor-field-name-transformation.svg?style=flat-square)](https://www.npmjs.org/package/slonik-interceptor-field-name-transformation)
[![Canonical Code Style](https://img.shields.io/badge/code%20style-canonical-blue.svg?style=flat-square)](https://github.com/gajus/canonical)
[![Twitter Follow](https://img.shields.io/twitter/follow/kuizinas.svg?style=social&label=Follow)](https://twitter.com/kuizinas)

Transforms [Slonik](https://github.com/gajus/slonik) query result field names into camelCase.

## Motivation

This interceptor removes the necessity to alias field names, e.g.

```ts
connection.any(sql`
  SELECT
    id,
    full_name "fullName"
  FROM person
`);
```

Field name transformation uses the `afterQuery` interceptor method to format field names.

## Installation

```bash
npm install slonik-interceptor-field-name-transformation
```

## Configuration

You can configure which fields should be transformed by providing a `test` function to `createFieldNameTransformationInterceptor`

```ts
/**
 * @property test Tests whether the field should be formatted.
 * All fields that pass this test will have their names converted to camelCase.
 */
type ConfigurationType = {
  test: (field: FieldType) => boolean;
};

(configuration: ConfigurationType) => InterceptorType;
```

## Example usage

```ts
import { createPool } from "slonik";
import { createFieldNameTransformationInterceptor } from "slonik-interceptor-field-name-transformation";

const interceptors = [
  createFieldNameTransformationInterceptor({
    test: (field) => {
      return field.name !== "__typename" && /^[\d_a-z]+$/u.test(field.name);
    },
  }),
];

const connection = createPool("postgres://", {
  interceptors,
});

connection.any(sql`
  SELECT
    id,
    full_name,
    __typename
  FROM person
`);

// [
//   {
//     id: 1,
//     fullName: 'John Doe',
//     __typename: 'person'
//   }
// ]
```

---
_Source: https://npm.io/package/slonik-interceptor-field-name-transformation · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
