{"id":14483718,"url":"https://github.com/gx0r/connect-session-knex","last_synced_at":"2025-12-25T18:53:05.045Z","repository":{"id":43481598,"uuid":"21397374","full_name":"gx0r/connect-session-knex","owner":"gx0r","description":"A knex.js session store for express-session, supporting PostgreSQL, MySQL, MariaDB, Oracle and SQLite.","archived":false,"fork":false,"pushed_at":"2023-11-04T13:54:38.000Z","size":767,"stargazers_count":89,"open_issues_count":22,"forks_count":64,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-05-17T14:41:53.273Z","etag":null,"topics":["express","knex","mysql","nodejs","oracle","postgresql","session","sqlite"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/connect-session-knex","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gx0r.png","metadata":{"files":{"readme":"Readme.md","changelog":"Changelog.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-07-01T17:58:02.000Z","updated_at":"2024-05-29T04:54:48.558Z","dependencies_parsed_at":"2023-01-31T01:15:33.672Z","dependency_job_id":"e4241998-4727-4d2e-bdc7-3da9c3dfc871","html_url":"https://github.com/gx0r/connect-session-knex","commit_stats":{"total_commits":249,"total_committers":47,"mean_commits":5.297872340425532,"dds":0.4257028112449799,"last_synced_commit":"4e0e36a9afbb13c3000a89f5e341f2d2d4339a02"},"previous_names":[],"tags_count":41,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gx0r%2Fconnect-session-knex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gx0r%2Fconnect-session-knex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gx0r%2Fconnect-session-knex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gx0r%2Fconnect-session-knex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gx0r","download_url":"https://codeload.github.com/gx0r/connect-session-knex/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":231017120,"owners_count":18315664,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["express","knex","mysql","nodejs","oracle","postgresql","session","sqlite"],"created_at":"2024-09-03T00:02:02.173Z","updated_at":"2025-12-25T18:53:05.012Z","avatar_url":"https://github.com/gx0r.png","language":"JavaScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# Connect Session Knex\n\n[![NPM Version][npm-version-image]][npm-url]\n[![NPM Downloads][npm-downloads-image]][npm-url]\n[![Node.js Version][node-image]][node-url]\n[![NPM][npm-image]][npm-url]\n\nconnect-session-knex is an [express-session](https://github.com/expressjs/session) store backed by PostgreSQL, MySQL, MariaDB, MSSQL, Oracle or SQLite3, via the [knex.js](http://knexjs.org/) library.\n\n## Installation\n\n```sh\n$ npm install connect-session-knex\n```\n\n## History\n\nSee [Changelog.md](Changelog.md)\n\n## Usage\n\n[Example application using the defaults](https://github.com/gx0r/connect-session-knex/blob/master/examples/example-mjs.mjs)\n\n[Example application with PostgreSQL](https://github.com/gx0r/connect-session-knex/blob/master/examples/example-postgres.mjs)\n\n## Options\n\n- `cleanupInterval` milliseconds between clearing expired sessions. Defaults to 60000. 0 disables the automatic clearing of expired sessions.\n- `createTable` if the table for sessions should be created automatically or not.\n- `knex` knex instance to use. Defaults to a new knex instance, using sqlite3 with a file named 'connect-session-knex.sqlite'\n- `tableName='sessions'` Tablename to use. Defaults to 'sessions'.\n- `sidFieldName='sid'` Field name in table to use for storing session ids. Defaults to 'sid'.\n\nIf the table does not exist in the schema, this module will attempt to create it unless the `createTable` option is false.\n\nIf a knex instance is not provided, this module will attempt to create a sqlite3 database, with a file named `connect-session-knex.sqlite`, in the working directory of the process.\n\n## Schema\n\n### PostgreSQL or SQLite\n\n#### Table Name \"sessions\"\n\n| Column  |           Type           | Modifiers | Storage  |\n| ------- | :----------------------: | :-------: | :------: |\n| sid     |  character varying(255)  | not null  | extended |\n| sess    |           json           | not null  | extended |\n| expired | timestamp with time zone | not null  |  plain   |\n\n### Indexes:\n\n```\n    \"sessions_pkey\" PRIMARY KEY, btree (sid)\n    \"sessions_expired_index\" btree (expired)\n```\n\n### MySQL\n\nTable Name `sessions`.\n\n| Column  |     Type     |  Modifiers   |\n| ------- | :----------: | :----------: |\n| sid     | VARCHAR(255) | NOT NULL, PK |\n| sess    |     JSON     |   NOT NULL   |\n| expired |   DATETIME   |   NOT NULL   |\n\nCommand to manually create table:\n\n```sql\nCREATE TABLE `sessions` (\n  `sid` VARCHAR(255) NOT NULL,\n  `sess` JSON NOT NULL,\n  `expired` DATETIME NOT NULL,\n  PRIMARY KEY (`sid`));\n```\n\n[npm-version-image]: https://img.shields.io/npm/v/connect-session-knex.svg\n[npm-downloads-image]: https://img.shields.io/npm/dm/connect-session-knex.svg\n[npm-image]: https://nodei.co/npm/connect-session-knex.png?downloads=true\u0026downloadRank=true\u0026stars=true\n[npm-url]: https://npmjs.org/package/connect-session-knex\n[travis-image]: https://img.shields.io/travis/gx0r/connect-session-knex/master.svg\n[travis-url]: https://travis-ci.org/gx0r/connect-session-knex\n[node-image]: https://img.shields.io/node/v/connect-session-knex.svg\n[node-url]: http://nodejs.org/download/\n\n## Testing\n\nInstall Postgresql\n\nInstructions for Ubuntu after intalling the db:\n\n```bash\nsudo -u postgres psql\n```\n\n```sql\nCREATE DATABASE travis_ci_test OWNER postgres;\n```\n\n```sql\nGRANT all privileges ON DATABASE travis_ci_test TO postgres;\n```\n\n```sql\nALTER USER postgres WITH PASSWORD 'postgres';\n```\n\n```sql\n\\q\n```\n\nInstall Mysql\n\nInstructions for Ubuntu after installing the db:\n\n```bash\nsudo mysql -u root\n```\n\n```sql\ncreate user 'travis' identified by 'travis';\n```\n\n```sql\nALTER USER 'travis'@'localhost' IDENTIFIED BY 'travis';\n```\n\n```sql\ncreate database travis_ci_test;\n```\n\n```sql\ngrant all on travis_ci_test.* to 'travis';\n```\n\n```sql\n\\q\n```\n\n```bash\nsudo service mysql restart\n```\n\nMake sure both the MySQL and Postgres services are running\n\n```bash\nnpm run test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgx0r%2Fconnect-session-knex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgx0r%2Fconnect-session-knex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgx0r%2Fconnect-session-knex/lists"}