# sql-params

> Use anonymous objects instead of arrays when using parametric SQL queries.

Latest version **1.0.1** (published 2014-06-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install sql-params
pnpm add sql-params
yarn add sql-params
bun add sql-params
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2014-06-25 |
| First published | 2014-06-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Brandon Valosek |
| Maintainers | bvalosek |

## Links

- npm: https://www.npmjs.com/package/sql-params
- Repository: git@github.com:bvalosek/sql-params
- Homepage: https://github.com/bvalosek/sql-params
- Issues: https://github.com/bvalosek/sql-params/issues
- npm.io page: https://npm.io/package/sql-params

## Recent versions

- 1.0.1 (latest) — 2014-06-25
- 1.0.0 — 2014-06-10

## README

# sql-params

[![Build Status](https://travis-ci.org/bvalosek/sql-params.png?branch=master)](https://travis-ci.org/bvalosek/sql-params)
[![NPM version](https://badge.fury.io/js/sql-params.png)](http://badge.fury.io/js/sql-params)

Use anonymous objects instead of arrays when using parametric SQL queries.

## Installation

```
$ npm install sql-params
```

## Usage

```javascript
var sqlParams = require('sql-params');

var sql    = 'select * from user where points > @points and id = @id';
var params = { points: 24, id: 123 };

var opts = sqlParams(sql, params);
```

Returns a hash with the `pg`-ready parametric SQL string and array of values:

```javascript
{
  text   : 'select * from user where points > $1 and id = $2',
  values : [24, 123]
}
```

You can even pass it directly when using the `query` method with the `pg`
driver:

```javascript
pg.connect(URL, function(err, client) {
  client.query(sqlParams(sql, params), function(err, result) {

    ...

  });
});
```

## Testing

```
$ npm test
```

## License

MIT

---
_Source: https://npm.io/package/sql-params · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
