{"id":20170162,"url":"https://github.com/fabrix-app/spool-knex","last_synced_at":"2025-08-11T19:10:41.949Z","repository":{"id":47433218,"uuid":"140325725","full_name":"fabrix-app/spool-knex","owner":"fabrix-app","description":"Spool: Knex Datastore","archived":false,"fork":false,"pushed_at":"2023-01-11T01:47:13.000Z","size":642,"stargazers_count":3,"open_issues_count":12,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-17T22:55:08.035Z","etag":null,"topics":["fabrix","knex","nodejs","orm","spools","typescript"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fabrix-app.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-07-09T18:20:36.000Z","updated_at":"2019-11-01T23:25:59.000Z","dependencies_parsed_at":"2023-02-08T22:00:25.323Z","dependency_job_id":null,"html_url":"https://github.com/fabrix-app/spool-knex","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabrix-app%2Fspool-knex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabrix-app%2Fspool-knex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabrix-app%2Fspool-knex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabrix-app%2Fspool-knex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fabrix-app","download_url":"https://codeload.github.com/fabrix-app/spool-knex/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248143673,"owners_count":21054819,"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":["fabrix","knex","nodejs","orm","spools","typescript"],"created_at":"2024-11-14T01:17:30.874Z","updated_at":"2025-04-10T02:25:59.162Z","avatar_url":"https://github.com/fabrix-app.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# spool-knex\n\n[![Gitter][gitter-image]][gitter-url]\n[![NPM version][npm-image]][npm-url]\n[![Build Status][ci-image]][ci-url]\n[![Test Coverage][coverage-image]][coverage-url]\n[![Dependency Status][daviddm-image]][daviddm-url]\n[![Follow @FabrixApp on Twitter][twitter-image]][twitter-url]\n\nProvides support for database queries and schema migrations via [knex.js](http://knexjs.org/).\n\n## Install\n\n```sh\n$ npm install --save @fabrix/spool-knex\n```\n\n## Configure\n\n#### `main.ts`\n\n```js\n// config/main.ts\nexport const main = {\n  spools: [\n    // ... other spools\n    require('@fabrix/spool-knex').KnexSpool\n  ]\n}\n```\n\n#### `database.ts`\n\n```js\n// config/stores.ts\nexport const stores = {\n  knexPostgres: {\n    orm: 'knex',\n    client: 'pg',\n\n    /**\n     * knex connection object\n     * see: http://knexjs.org/#Installation-client\n     */\n    connection: {\n      host: 'localhost',\n      user: 'admin',\n      password: '1234',\n      database: 'mydb'\n    }\n  }\n}\n// config/models.ts\nexport const models = {\n  /**\n   * Supported Migrate Settings:\n   * - drop\n   * - create\n   */\n  migrate: 'create',\n  defaultStore: 'knexPostgres'\n}\n```\n\n## Usage\n\n### Models\n\n```js\n// api/models/User.ts\nclass User extends Model {\n  static schema (app, table) {\n    table.increments('id').primary()\n    table.string('username')\n    table.string('firstName')\n    table.string('lastName')\n  }\n}\n\n// api/models/Role.ts\nclass Role extends Model {\n  static schema (app, table) {\n    table.increments('id').primary()\n    table.string('name')\n    table.integer('user_id').references('user.id')\n  }\n}\n```\n\n### Services\n\n#### `SchemaMigrationService`\n\n##### `create`\nCreate the schema using knex\n\n##### `drop`\nDrop the schema using knex\n\n##### `alter`\nNot currently supported.\n\n## Contributing\nWe love contributions! Please check out our [Contributor's Guide](https://github.com/fabrix-app/fabrix/blob/master/.github/CONTRIBUTING.md) for more\ninformation on how our projects are organized and how to get started.\n\n## License\n[MIT](https://github.com/fabrix-app/fabrix/blob/master/LICENSE)\n\n[npm-image]: https://img.shields.io/npm/v/@fabrix/spool-knex.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/@fabrix/spool-knex\n[ci-image]: https://img.shields.io/circleci/project/github/fabrix-app/spool-knex/master.svg\n[ci-url]: https://circleci.com/gh/fabrix-app/spool-knex/tree/master\n[daviddm-image]: http://img.shields.io/david/fabrix-app/spool-knex.svg?style=flat-square\n[daviddm-url]: https://david-dm.org/fabrix-app/spool-knex\n[gitter-image]: http://img.shields.io/badge/+%20GITTER-JOIN%20CHAT%20%E2%86%92-1DCE73.svg?style=flat-square\n[gitter-url]: https://gitter.im/fabrix-app/fabrix\n[twitter-image]: https://img.shields.io/twitter/follow/FabrixApp.svg?style=social\n[twitter-url]: https://twitter.com/FabrixApp\n[coverage-image]: https://img.shields.io/codeclimate/coverage/github/fabrix-app/spool-knex.svg?style=flat-square\n[coverage-url]: https://codeclimate.com/github/fabrix-app/spool-knex/coverage\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffabrix-app%2Fspool-knex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffabrix-app%2Fspool-knex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffabrix-app%2Fspool-knex/lists"}