{"_id":"@cmelgarejo/nestjsknexjs","_rev":"3-f1e7da5690307e60e8d982303792b3fc","name":"@cmelgarejo/nestjsknexjs","dist-tags":{"latest":"0.0.5","next":"0.0.4"},"versions":{"0.0.3":{"name":"@cmelgarejo/nestjsknexjs","version":"0.0.3","description":"KnexJS module for NestJS framework","author":{"name":"cmelgarejo"},"contributors":[{"name":"Tony133"}],"license":"MIT","scripts":{"build":"rm -rf dist && tsc -p tsconfig.json","format":"prettier --write \"**/*.ts\"","lint":"eslint 'lib/**/*.ts' --fix","prepublish:npm":"npm run build","publish:npm":"npm publish --access public","prepublish:next":"npm run build","publish:next":"npm publish --access public --tag next","test:e2e":"jest --config ./tests/jest-e2e.json --runInBand","test:e2e:dev":"jest --config ./tests/jest-e2e.json --runInBand --watchAll","prerelease":"npm run build","release":"release-it"},"devDependencies":{"@commitlint/cli":"12.1.1","@commitlint/config-angular":"12.1.1","@nestjs/common":"7.6.15","@nestjs/core":"7.6.15","@nestjs/platform-express":"7.6.15","@nestjs/testing":"7.6.15","@types/express":"4.17.11","@types/jest":"26.0.22","@types/node":"14.14.40","@types/supertest":"2.0.11","@typescript-eslint/eslint-plugin":"4.22.0","@typescript-eslint/parser":"4.22.0","eslint":"7.24.0","eslint-config-prettier":"8.2.0","eslint-plugin-import":"2.22.1","husky":"6.0.0","jest":"26.6.3","knex":"0.95.4","mysql":"2.18.1","prettier":"2.2.1","reflect-metadata":"0.1.13","release-it":"14.6.1","rxjs":"6.6.7","supertest":"6.1.3","ts-jest":"26.5.5","ts-node":"9.1.1","tsconfig-paths":"3.9.0","typescript":"4.2.4"},"peerDependencies":{"@nestjs/common":"^7.6.15","@nestjs/core":"^7.6.15","knex":"^0.95.4","reflect-metadata":"^0.1.13","rxjs":"^6.6.7"},"lint-staged":{"*.ts":["prettier --write"]},"husky":{"hooks":{"commit-msg":"commitlint -c .commitlintrc.json -E HUSKY_GIT_PARAMS","pre-commit":"lint-staged"}},"repository":{"type":"git","url":"git+https://github.com/loopcontext/nestjsknexjs.git"},"dependencies":{"pg":"^8.6.0"},"gitHead":"862d5a2cb3ebe817462a234d1e3673dcd3f7c048","bugs":{"url":"https://github.com/loopcontext/nestjsknexjs/issues"},"homepage":"https://github.com/loopcontext/nestjsknexjs#readme","_id":"@cmelgarejo/nestjsknexjs@0.0.3","_nodeVersion":"15.12.0","_npmVersion":"7.7.5","dist":{"integrity":"sha512-jdtDV9b7AHLm5IlShdYjzbA2VyB+0GIoA/4KW1Ayd1/NEtaAvewqh+Xx4K/r5TpxZHZdx4bgNDS0thdkzKjABQ==","shasum":"0846d4677666eab06be9407a3311d2eb722da448","tarball":"https://registry.npmjs.org/@cmelgarejo/nestjsknexjs/-/nestjsknexjs-0.0.3.tgz","fileCount":50,"unpackedSize":35190,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgeGvOCRA9TVsSAnZWagAAs6MP/3Lw6bZgf7PBCFp/hHmM\nfS/tXsKUY1Zxw+kJdUrfPPS8GIRAMLRa5Gp5B/GSf6ZF7RIbZIXwHaP4GRmK\nj1jMZ1OJFJ/c76B7Wrx0xt5uH3cOthE9VLSjFjQgE/7VHIGF0kZLf4RncifG\nbomxh9SuqFCb+lYp6Fx88ADMd3AmgBgC0IGl44XfRC+nW7b9GxOgMnDK9aUg\nmMvFbdl7BCre53pRKPOW9+xMm0rffy6QkSECVBjPi8C2ibxAIwoBa7GqvHst\nxXTqjnt+tpEAFPSj6reBFQV6yLIxD1odaXAWNbDSD213pWcHQf9EQdXTqLqp\nEESoEk1LcvcxqyFEbtvUlL5WTrsRyvc+RY3K/LaVvBuBqulF+6XnvaEAhTPz\nZfnx7ecGtDNznL6omO+17OTK5i0QuHlKXRY6HtyswohfDLlLIOAVTFiRYR8N\nHswN8IDmWp6HCh+dHuX1XSv3T7PSoopEyUSsPNBlRgBqcyWkxsgefcd/ULj3\nMBjWJ85E2EvwrAg0bQas4nggy6fOC+mEBZoTSgU1kmLoAAENhh+J+qjlfF2k\nSHeg1TFMYAv9BjzZi8nIZ4ZH7DQhNXfKZGbDqeBE6Lb7LhwosZwTDDvCJVKp\nBMNyI7A8daxMr7TPR4RVSLbbVJS3RPXs0qVH1LD17AQDTxnms9GdJhkBwGYx\n8fQs\r\n=nezQ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCHwsRUHkoTyEF75aq7DOxLGz0/SmbE2PMnmxDbfWLZ20CIQDuLrN8pgDPpv9ojy3vhot0nGTXngUWTXkJeDzmaz8VCw=="}]},"_npmUser":{"name":"cmelgarejo","email":"cmelgarejo.dev@gmail.com"},"directories":{},"maintainers":[{"name":"cmelgarejo","email":"cmelgarejo.dev@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/nestjsknexjs_0.0.3_1618504654138_0.3815936355919234"},"_hasShrinkwrap":false},"0.0.4":{"name":"@cmelgarejo/nestjsknexjs","version":"0.0.4","description":"KnexJS module for NestJS framework","author":{"name":"cmelgarejo"},"contributors":[{"name":"Tony133"}],"license":"MIT","scripts":{"build":"rm -rf dist && tsc -p tsconfig.json","format":"prettier --write \"**/*.ts\"","lint":"eslint 'lib/**/*.ts' --fix","prepublish:npm":"npm run build","publish:npm":"npm publish --access public","prepublish:next":"npm run build","publish:next":"npm publish --access public --tag next","test:e2e":"jest --config ./tests/jest-e2e.json --runInBand","test:e2e:dev":"jest --config ./tests/jest-e2e.json --runInBand --watchAll","prerelease":"npm run build","release":"release-it"},"devDependencies":{"@commitlint/cli":"12.1.1","@commitlint/config-angular":"12.1.1","@nestjs/common":"7.6.15","@nestjs/core":"7.6.15","@nestjs/platform-express":"7.6.15","@nestjs/testing":"7.6.15","@types/express":"4.17.11","@types/jest":"26.0.22","@types/node":"14.14.40","@types/supertest":"2.0.11","@typescript-eslint/eslint-plugin":"4.22.0","@typescript-eslint/parser":"4.22.0","eslint":"7.24.0","eslint-config-prettier":"8.2.0","eslint-plugin-import":"2.22.1","husky":"6.0.0","jest":"26.6.3","knex":"0.95.4","mysql":"2.18.1","prettier":"2.2.1","reflect-metadata":"0.1.13","release-it":"14.6.1","rxjs":"6.6.7","supertest":"6.1.3","ts-jest":"26.5.5","ts-node":"9.1.1","tsconfig-paths":"3.9.0","typescript":"4.2.4"},"peerDependencies":{"@nestjs/common":"^7.6.15","@nestjs/core":"^7.6.15","knex":"^0.95.4","reflect-metadata":"^0.1.13","rxjs":"^6.6.7"},"lint-staged":{"*.ts":["prettier --write"]},"husky":{"hooks":{"commit-msg":"commitlint -c .commitlintrc.json -E HUSKY_GIT_PARAMS","pre-commit":"lint-staged"}},"repository":{"type":"git","url":"git+https://github.com/loopcontext/nestjsknexjs.git"},"readme":"# nestjsknexjs\n\n![nestjsknexjs](https://nestjs.com/img/logo_text.svg)\n\n## Description\n\nKnexjs module for Nest framework (node.js)\n\n## Installation\n\nFirst install the module via `yarn` or `npm` and do not forget to install the driver package as well:\n\n```bash\n    npm i --save nestjsknexjs knex mysql   # for mysql/mariadb\n    npm i --save nestjsknexjs knex pg      # for postgresql\n    npm i --save nestjsknexjs knex sqlite  # for sqlite\n```\n\nor\n\n```bash\n    yarn add nestjsknexjs knex mysql   # for mysql/mariadb\n    yarn add nestjsknexjs knex pg      # for postgresql\n    yarn add nestjsknexjs knex sqlite  # for sqlite\n```\n\n## Table of Contents\n\n- [Description](#description)\n- [Table of Contents](#table-of-contents)\n- [Usage](#usage)\n  - [KnexModule](#knexmodule)\n  - [ExampleOfUse](#example-of-use)\n  - [CreateMigrations](#create-migrations)\n  - [RunMigrations](#run-migrations)\n  - [CreateSeeds](#create-seeds)\n  - [RunSeeds](#run-seeds)\n\n## Usage\n\n### KnexModule\n\nKnexModule is the primary entry point for this package and can be used synchronously\n\n```typescript\n@Module({\n  imports: [\n    KnexModule.forRoot({\n      config: {\n        client: 'pg',\n        connection: {\n          host: '127.0.0.1',\n          port: 5432,\n          user: 'postgres',\n          password: 'pgsql',\n          database: 'test',\n        },\n      },\n    }),\n  ],\n})\n```\n\nor asynchronously\n\n```typescript\n@Module({\n  imports: [\n    KnexModule.forRootAsync({\n      useFactory: () => ({\n        config: {\n          client: 'pg',\n          connection: {\n            host: '127.0.0.1',\n            port: 5432,\n            user: 'postgres',\n            password: 'pgsql',\n            database: 'test',\n          },\n        },\n      }),\n    }),\n  ],\n})\n```\n\n## Example of use\n\nUsersService:\n\n```typescript\nimport { Injectable } from '@nestjs/common';\nimport Knex from 'knex';\nimport { InjectModel } from 'nestjsknexjs';\n\n@Injectable()\nexport class UsersService {\n  constructor(@InjectModel() private readonly knex: Knex) {}\n\n  async findAll() {\n    const users = await this.knex.table('users');\n    return { users };\n  }\n}\n```\n\nUsersController:\n\n```typescript\nimport { Controller, Get } from '@nestjs/common';\nimport { UsersService } from './users.service';\n\n@Controller()\nexport class UsersController {\n  constructor(private readonly usersService: UsersService) {}\n\n  @Get()\n  async getHello() {\n    return await this.usersService.findAll();\n  }\n}\n```\n\n## Create Migrations\n\n```bash\n  npx knex init\n  npx knex migrate:make [name_migrations]\n```\n\nExample file migrations:\n\n```typescript\nexports.up = function(knex) {\n  return knex.schema\n    .createTable('users', function(table) {\n      table.increments('id');\n      table.string('first_name', 255).notNullable();\n      table.string('last_name', 255).notNullable();\n    })\n    .createTable('products', function(table) {\n      table.increments('id');\n      table.string('name', 255).notNullable();\n      table.decimal('price').notNullable();\n    });\n};\n\nexports.down = function (knex) {\n  return knex.schema.dropTable('products').dropTable('users');\n};\n```\n\n## Run Migrations\n\nIn `knexfile.js` update with your config settings:\n\n```javascript\nmodule.exports = {\n  development: {\n    client: 'mysql',\n    connection: {\n      host: '127.0.0.1',\n      user: 'root',\n      password: 'root',\n      database: 'test',\n    },\n  },\n}\n```\n\nthen we run the following command from the terminal\n\n```bash\n  npx knex migrate:latest\n```\n\n## Create Seeds\n\n```bash\n  npx knex seed:make [name_seed]\n```\n\nExample file seeds\n\n```javascript\nexports.seed = function (knex) {\n  return knex('users')\n    .del()\n    .then(function () {\n      return knex('users').insert([\n        { id: 1, first_name: 'firstname1', last_name: 'lastname1' },\n        { id: 2, first_name: 'firstname2', last_name: 'lastname2' },\n        { id: 3, first_name: 'firstname3', last_name: 'lastname3' },\n      ]);\n    });\n};\n```\n\n## Run Seeds\n\n```bash\n  npx knex seed:run\n```\n\nFor more information on `Knex.js` see [here](http://knexjs.org/)\n\n## Test locally\n\n### Run migration and tests\n\n```bash\n  cd tests; npx knex migrate:latest; npx knex seed:run; cd ..; npm run test:e2e\n```\n\n## Contribute\n\nFeel free to help this library, I'm quite busy with also another Nestjs packages, but the community will appreciate the effort of improving this library. Make sure you follow the guidelines\n\n## Stay in touch\n\n- Author - [cmelgarejo](https://github.com/cmelgarejo)\n- Original Author - [Tony133](https://github.com/Tony133)\n- Framework - [https://nestjs.com](https://nestjs.com/)\n\n## License\n\n [MIT licensed](LICENSE)\n","readmeFilename":"README.md","gitHead":"862d5a2cb3ebe817462a234d1e3673dcd3f7c048","bugs":{"url":"https://github.com/loopcontext/nestjsknexjs/issues"},"homepage":"https://github.com/loopcontext/nestjsknexjs#readme","_id":"@cmelgarejo/nestjsknexjs@0.0.4","_nodeVersion":"15.12.0","_npmVersion":"7.7.5","dist":{"integrity":"sha512-B7yUi7s6Fj4fKxIfRBD3gaipf2nnhX2jBtkvovOgOAsvnuxqjy4IIv5O94ds9mB02ZNcTM2p8w7fGMx8LEPsqg==","shasum":"c728eea37006faf1445f4b5c415e2917089b74fa","tarball":"https://registry.npmjs.org/@cmelgarejo/nestjsknexjs/-/nestjsknexjs-0.0.4.tgz","fileCount":50,"unpackedSize":35146,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgeIZqCRA9TVsSAnZWagAAwukP/is0g0q/x76vv7RBUvYY\nCTj5ENsT95M1t9caAFSJduEw8qqdoGFkC0cgPjBz1Okt8BFmpInZdCdOAEge\nvnivlG6U4K47GyiV12064duezJ/+WIGgWzupa+2C6Oyl6efRGNqgbTmP0P1y\nQryjJ4VpS8Kcm87G9Ue4n6/h2/TqcbyIWISGRFppRNokTV+5nzJL8gKmxrt6\nxxcIgxkpHotCqMznoUdRqI6FYNERtUBVr8kBtaYzw6F8VXWUswZkDs8ST9d5\nDjF4U0AkR0LWvxvynPlZvs6arKiVqAg3LYrlPqiZ2FGjp5rjF21bN8qHmcA5\nyfNmEUduR37W5JJZJBMGAJpgyT+795mWJposBn2Gfu5gRYGd9ykiXDLkNzd7\nI6xgpFVVfgxqWB4MkvdSNGcNFOFXhQNR8voFnnKPQ1CuGG7IvLy8O7ltE0S2\npbIXSwSp27DQcsA8jn5OnWr4VppJgX/ZzTAg5zKGhgg9pR1OFDUFrU61QwpU\nPLhUo+Tmo6BIvsm3Liru50NVI5CN6cgnnaPQTMLxFYURSFlJoRLXd4qE8wDj\n2cyMlNICbpd9v5MWesGt5h36Ttd9rVOiR3TMHsvRNaPBEWPLwGbLej0Q/pvd\ndnBnBO4x+SUJIW3avzF1pebxNQy+muxS2JWye0mwpE9fzd0v63N2kouMxemN\n1MD2\r\n=c7kJ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIG4erYUISDfg0rsF+BUJSzlfo6PG1PvwEUoMYCPDb0mDAiEA68RPq24rIm8N/v7fcpVbomJkKmjz/qGfasYlN85oY1Q="}]},"_npmUser":{"name":"cmelgarejo","email":"cmelgarejo.dev@gmail.com"},"directories":{},"maintainers":[{"name":"cmelgarejo","email":"cmelgarejo.dev@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/nestjsknexjs_0.0.4_1618511466512_0.6893444259268791"},"_hasShrinkwrap":false},"0.0.5":{"name":"@cmelgarejo/nestjsknexjs","version":"0.0.5","description":"KnexJS module for NestJS framework","author":{"name":"cmelgarejo"},"contributors":[{"name":"Tony133"}],"license":"MIT","scripts":{"build":"rm -rf dist && tsc -p tsconfig.json","format":"prettier --write \"**/*.ts\"","lint":"eslint 'lib/**/*.ts' --fix","prepublish:npm":"npm run build","publish:npm":"npm publish --access public","prepublish:next":"npm run build","publish:next":"npm publish --access public --tag next","test:e2e":"jest --config ./tests/jest-e2e.json --runInBand","test:e2e:dev":"jest --config ./tests/jest-e2e.json --runInBand --watchAll","prerelease":"npm run build","release":"release-it"},"devDependencies":{"@commitlint/cli":"12.1.1","@commitlint/config-angular":"12.1.1","@nestjs/common":"7.6.15","@nestjs/core":"7.6.15","@nestjs/platform-express":"7.6.15","@nestjs/testing":"7.6.15","@types/express":"4.17.11","@types/jest":"26.0.22","@types/node":"14.14.40","@types/supertest":"2.0.11","@typescript-eslint/eslint-plugin":"4.22.0","@typescript-eslint/parser":"4.22.0","eslint":"7.24.0","eslint-config-prettier":"8.2.0","eslint-plugin-import":"2.22.1","husky":"6.0.0","jest":"26.6.3","knex":"0.95.4","mysql":"2.18.1","prettier":"2.2.1","reflect-metadata":"0.1.13","release-it":"14.6.1","rxjs":"6.6.7","supertest":"6.1.3","ts-jest":"26.5.5","ts-node":"9.1.1","tsconfig-paths":"3.9.0","typescript":"4.2.4"},"peerDependencies":{"@nestjs/common":"^7.6.15","@nestjs/core":"^7.6.15","knex":"^0.95.4","reflect-metadata":"^0.1.13","rxjs":"^6.6.7"},"lint-staged":{"*.ts":["prettier --write"]},"husky":{"hooks":{"commit-msg":"commitlint -c .commitlintrc.json -E HUSKY_GIT_PARAMS","pre-commit":"lint-staged"}},"repository":{"type":"git","url":"git+https://github.com/loopcontext/nestjsknexjs.git"},"gitHead":"862d5a2cb3ebe817462a234d1e3673dcd3f7c048","bugs":{"url":"https://github.com/loopcontext/nestjsknexjs/issues"},"homepage":"https://github.com/loopcontext/nestjsknexjs#readme","_id":"@cmelgarejo/nestjsknexjs@0.0.5","_nodeVersion":"15.12.0","_npmVersion":"7.7.5","dist":{"integrity":"sha512-dwDf5ViX57gvcEQAqDU50P/z/7j1s3bbFIwFofe5QXtceLl09eC41rmZNe4jNY/XoJKQheLUmzh95He2PhleDQ==","shasum":"1065e65d0e5a94f56d3d728dd6bd89827d87635e","tarball":"https://registry.npmjs.org/@cmelgarejo/nestjsknexjs/-/nestjsknexjs-0.0.5.tgz","fileCount":50,"unpackedSize":35146,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgeIcSCRA9TVsSAnZWagAAXbEP/3PIyZV1LvEAJLWp5c5F\nLsbaHQf0ozHl6CEtrIbvAIOiFZJ4kh7aIaswpwCaxmCnq569CmNfklZ06AaB\nnAGVEBJ39cl8YdFTmIhFEoiWzSFOx6K6h+Fvw+1Rxkd1RydFUwQaoZ2zbGxP\nPDEKuCspru31LVcjCo4NIyKRnRd9gqh8r4VOauv4PhTTVBXVkz2sAzn5pppg\nleQH3AbpNVC5jwebxCNT8kzsKFHYatkVApmEdcAx5uxAnQ5p7G+Ub4uVd1jO\nX3A1N9yhXZq+pAIDBDiZig8LMdrx2GPG+PckYhYbL423jumTrEnlT2CNheew\nXa70Bh8HDVG06FcSgYBgs3Dccklt4df+kY//0DJhvdajEfoRBskHrT0BCoLm\nDN1r8eUSTIAUy1IudYib3NVViW7YzdCFE6tIY31V+xTRF3BVDt//uEG6hg2J\nGOzBj9nrPhlGNzX5S5yCMbBbz3gY2b4mmMko8G3mqg7w5jkvfQ0OAN81Fk1v\n6QRyITqPNFDtjXGw5D0ucP05rRT0u72lnjFEcRq6noq9tbo2IbGPs9i8AFWZ\nCCtt5kw2We452bworfRk7fT2LR187HeQQy0cenbK/jW+CA5TVqMCdVkSivOd\nUoUEjNhfZQ1ZU9PhYFxlEosPbedbbJBg7SQ76zyda7Xb/8FfaF0+C5AwHNpF\npV6H\r\n=atC4\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD9RZVqZ8jiTNMx5WU8iGo5w//z4XVzWQU9WdnaE6ymaAIhAL0DG+Wn1C0/R8f37Jhkyh8XgkQyZ3m8SrG7U9tipjG/"}]},"_npmUser":{"name":"cmelgarejo","email":"cmelgarejo.dev@gmail.com"},"directories":{},"maintainers":[{"name":"cmelgarejo","email":"cmelgarejo.dev@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/nestjsknexjs_0.0.5_1618511634066_0.9915558248253009"},"_hasShrinkwrap":false}},"time":{"created":"2021-04-15T16:37:34.087Z","0.0.3":"2021-04-15T16:37:34.319Z","modified":"2022-04-04T23:43:17.352Z","0.0.4":"2021-04-15T18:31:06.710Z","0.0.5":"2021-04-15T18:33:54.230Z"},"maintainers":[{"name":"cmelgarejo","email":"cmelgarejo.dev@gmail.com"}],"description":"KnexJS module for NestJS framework","homepage":"https://github.com/loopcontext/nestjsknexjs#readme","repository":{"type":"git","url":"git+https://github.com/loopcontext/nestjsknexjs.git"},"contributors":[{"name":"Tony133"}],"author":{"name":"cmelgarejo"},"bugs":{"url":"https://github.com/loopcontext/nestjsknexjs/issues"},"license":"MIT","readme":"# nestjsknexjs\n\n![nestjsknexjs](https://nestjs.com/img/logo_text.svg)\n\n## Description\n\nKnexjs module for Nest framework (node.js)\n\n## Installation\n\nFirst install the module via `yarn` or `npm` and do not forget to install the driver package as well:\n\n```bash\n    npm i --save nestjsknexjs knex mysql   # for mysql/mariadb\n    npm i --save nestjsknexjs knex pg      # for postgresql\n    npm i --save nestjsknexjs knex sqlite  # for sqlite\n```\n\nor\n\n```bash\n    yarn add nestjsknexjs knex mysql   # for mysql/mariadb\n    yarn add nestjsknexjs knex pg      # for postgresql\n    yarn add nestjsknexjs knex sqlite  # for sqlite\n```\n\n## Table of Contents\n\n- [Description](#description)\n- [Table of Contents](#table-of-contents)\n- [Usage](#usage)\n  - [KnexModule](#knexmodule)\n  - [ExampleOfUse](#example-of-use)\n  - [CreateMigrations](#create-migrations)\n  - [RunMigrations](#run-migrations)\n  - [CreateSeeds](#create-seeds)\n  - [RunSeeds](#run-seeds)\n\n## Usage\n\n### KnexModule\n\nKnexModule is the primary entry point for this package and can be used synchronously\n\n```typescript\n@Module({\n  imports: [\n    KnexModule.forRoot({\n      config: {\n        client: 'pg',\n        connection: {\n          host: '127.0.0.1',\n          port: 5432,\n          user: 'postgres',\n          password: 'pgsql',\n          database: 'test',\n        },\n      },\n    }),\n  ],\n})\n```\n\nor asynchronously\n\n```typescript\n@Module({\n  imports: [\n    KnexModule.forRootAsync({\n      useFactory: () => ({\n        config: {\n          client: 'pg',\n          connection: {\n            host: '127.0.0.1',\n            port: 5432,\n            user: 'postgres',\n            password: 'pgsql',\n            database: 'test',\n          },\n        },\n      }),\n    }),\n  ],\n})\n```\n\n## Example of use\n\nUsersService:\n\n```typescript\nimport { Injectable } from '@nestjs/common';\nimport Knex from 'knex';\nimport { InjectModel } from 'nestjsknexjs';\n\n@Injectable()\nexport class UsersService {\n  constructor(@InjectModel() private readonly knex: Knex) {}\n\n  async findAll() {\n    const users = await this.knex.table('users');\n    return { users };\n  }\n}\n```\n\nUsersController:\n\n```typescript\nimport { Controller, Get } from '@nestjs/common';\nimport { UsersService } from './users.service';\n\n@Controller()\nexport class UsersController {\n  constructor(private readonly usersService: UsersService) {}\n\n  @Get()\n  async getHello() {\n    return await this.usersService.findAll();\n  }\n}\n```\n\n## Create Migrations\n\n```bash\n  npx knex init\n  npx knex migrate:make [name_migrations]\n```\n\nExample file migrations:\n\n```typescript\nexports.up = function(knex) {\n  return knex.schema\n    .createTable('users', function(table) {\n      table.increments('id');\n      table.string('first_name', 255).notNullable();\n      table.string('last_name', 255).notNullable();\n    })\n    .createTable('products', function(table) {\n      table.increments('id');\n      table.string('name', 255).notNullable();\n      table.decimal('price').notNullable();\n    });\n};\n\nexports.down = function (knex) {\n  return knex.schema.dropTable('products').dropTable('users');\n};\n```\n\n## Run Migrations\n\nIn `knexfile.js` update with your config settings:\n\n```javascript\nmodule.exports = {\n  development: {\n    client: 'mysql',\n    connection: {\n      host: '127.0.0.1',\n      user: 'root',\n      password: 'root',\n      database: 'test',\n    },\n  },\n}\n```\n\nthen we run the following command from the terminal\n\n```bash\n  npx knex migrate:latest\n```\n\n## Create Seeds\n\n```bash\n  npx knex seed:make [name_seed]\n```\n\nExample file seeds\n\n```javascript\nexports.seed = function (knex) {\n  return knex('users')\n    .del()\n    .then(function () {\n      return knex('users').insert([\n        { id: 1, first_name: 'firstname1', last_name: 'lastname1' },\n        { id: 2, first_name: 'firstname2', last_name: 'lastname2' },\n        { id: 3, first_name: 'firstname3', last_name: 'lastname3' },\n      ]);\n    });\n};\n```\n\n## Run Seeds\n\n```bash\n  npx knex seed:run\n```\n\nFor more information on `Knex.js` see [here](http://knexjs.org/)\n\n## Test locally\n\n### Run migration and tests\n\n```bash\n  cd tests; npx knex migrate:latest; npx knex seed:run; cd ..; npm run test:e2e\n```\n\n## Contribute\n\nFeel free to help this library, I'm quite busy with also another Nestjs packages, but the community will appreciate the effort of improving this library. Make sure you follow the guidelines\n\n## Stay in touch\n\n- Author - [cmelgarejo](https://github.com/cmelgarejo)\n- Original Author - [Tony133](https://github.com/Tony133)\n- Framework - [https://nestjs.com](https://nestjs.com/)\n\n## License\n\n [MIT licensed](LICENSE)\n","readmeFilename":"README.md"}