# session-knex-pg

> A session store using Knex.js for PostgreSQL

Latest version **1.4.0** (published 2020-01-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install session-knex-pg
pnpm add session-knex-pg
yarn add session-knex-pg
bun add session-knex-pg
```

## 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.4.0 |
| Published | 2020-01-27 |
| First published | 2018-10-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | cesarrdzs |
| Maintainers | crodriguezs |
| Keywords | session, store, knex, postgresql |

## Links

- npm: https://www.npmjs.com/package/session-knex-pg
- Repository: https://github.com/cesarrdzs/session-knex-pg
- Homepage: https://github.com/cesarrdzs/session-knex-pg#readme
- Issues: https://github.com/cesarrdzs/session-knex-pg/issues
- npm.io page: https://npm.io/package/session-knex-pg

## Alternatives

- [@pothos/plugin-authz](https://npm.io/package/@pothos/plugin-authz.md) — 12.4K weekly downloads
- [@bounded-sh/client](https://npm.io/package/@bounded-sh/client.md) — 3.2K weekly downloads
- [@luigi-project/plugin-auth-oauth2](https://npm.io/package/@luigi-project/plugin-auth-oauth2.md) — 2.3K weekly downloads
- [@nocobase/plugin-verification](https://npm.io/package/@nocobase/plugin-verification.md) — 2.0K weekly downloads
- [escher-request](https://npm.io/package/escher-request.md) — 545 weekly downloads

## Recent versions

- 1.4.0 (latest) — 2020-01-27
- 1.3.0 — 2020-01-24
- 1.2.0 — 2019-12-12
- 1.1.1 — 2018-10-25
- 1.1.0 — 2018-10-15
- 1.0.0 — 2018-10-15

## README

A session store using Knex.js for PostgreSQL

## Installation

```sh
$ npm install -g session-knex-pg
```

## Usage

Simple example:

```javascript
const KnexStore = require('session-knex-pg');

app.use(session({
  store: new KnexStore(knexConnection, {
      schemaName: 'mySchema',
      tableName: 'sessions',
      gcFrecuency: 10000,
      browserSessionLifetime: 86400 * 1000
  }),
  secret: process.env.FOO_COOKIE_SECRET,
  resave: false,
  saveUninitialized: false,
  cookie: { maxAge: 30 * 24 * 60 * 60 * 1000 } // 30 days
}));
```

## Advanced options

* **schemaName** - Name of the schema in the database (default: public).
* **tableName** - Name of the session table in the database (default: sessions).
* **sync** - Create the sessions table if it doesnt exist (default: false).
* **syncTimeout** - If **sync** is true, how long to wait, in ms, for the sync to complete (default: 3000)
* **gcFrecuency** - Do garbage collection after approximately this many requests. This deletes expired session data from the table. Set to 0 to never do garbage collection. (default: 10000, or approximately every 10,000 requests)
* **timestamps** - If true, the table will have updated_at and created_at columns. (default: false)
* **browserSessionLifetime** - How long, in ms, to remember sessions without a TTL: sessions that only last until the browser is closed. Some session managers, will ignore this and use a reasonable default. (default: 86400000)

## License

[MIT](LICENSE)

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