{"id":18862201,"url":"https://github.com/hapinessjs/sequelize-module","last_synced_at":"2026-02-09T22:30:20.360Z","repository":{"id":57115153,"uuid":"112598999","full_name":"hapinessjs/sequelize-module","owner":"hapinessjs","description":"Sequelize integration for Hapiness framework","archived":false,"fork":false,"pushed_at":"2017-12-07T13:31:45.000Z","size":257,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-04-25T13:01:59.877Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hapinessjs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-30T10:37:28.000Z","updated_at":"2019-06-09T00:30:43.000Z","dependencies_parsed_at":"2022-08-22T10:40:07.145Z","dependency_job_id":null,"html_url":"https://github.com/hapinessjs/sequelize-module","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hapinessjs%2Fsequelize-module","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hapinessjs%2Fsequelize-module/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hapinessjs%2Fsequelize-module/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hapinessjs%2Fsequelize-module/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hapinessjs","download_url":"https://codeload.github.com/hapinessjs/sequelize-module/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239803161,"owners_count":19699622,"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":[],"created_at":"2024-11-08T04:33:37.721Z","updated_at":"2026-02-09T22:30:20.316Z","avatar_url":"https://github.com/hapinessjs.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"http://bit.ly/2mxmKKI\" width=\"500\" alt=\"Hapiness\" /\u003e\n\n\u003cdiv style=\"margin-bottom:20px;\"\u003e\n    \u003cdiv style=\"line-height:60px\"\u003e\n        \u003ca href=\"https://travis-ci.org/hapinessjs/sequelize-module.svg?branch=master\"\u003e\n            \u003cimg src=\"https://travis-ci.org/hapinessjs/sequelize-module.svg?branch=master\" alt=\"build\" /\u003e\n        \u003c/a\u003e\n        \u003ca href=\"https://coveralls.io/github/hapinessjs/sequelize-module?branch=master\"\u003e\n            \u003cimg src=\"https://coveralls.io/repos/github/hapinessjs/sequelize-module/badge.svg?branch=master\" alt=\"coveralls\" /\u003e\n        \u003c/a\u003e\n        \u003ca href=\"https://david-dm.org/hapinessjs/sequelize-module\"\u003e\n            \u003cimg src=\"https://david-dm.org/hapinessjs/sequelize-module.svg\" alt=\"dependencies\" /\u003e\n        \u003c/a\u003e\n        \u003ca href=\"https://david-dm.org/hapinessjs/sequelize-module?type=dev\"\u003e\n            \u003cimg src=\"https://david-dm.org/hapinessjs/sequelize-module/dev-status.svg\" alt=\"devDependencies\" /\u003e\n        \u003c/a\u003e\n    \u003c/div\u003e\n    \u003cdiv\u003e\n        \u003ca href=\"https://www.typescriptlang.org/docs/tutorial.html\"\u003e\n            \u003cimg src=\"https://cdn-images-1.medium.com/max/800/1*8lKzkDJVWuVbqumysxMRYw.png\"\n                align=\"right\" alt=\"Typescript logo\" width=\"50\" height=\"50\" style=\"border:none;\" /\u003e\n        \u003c/a\u003e\n        \u003ca href=\"http://reactivex.io/rxjs\"\u003e\n            \u003cimg src=\"http://reactivex.io/assets/Rx_Logo_S.png\"\n                align=\"right\" alt=\"ReactiveX logo\" width=\"50\" height=\"50\" style=\"border:none;\" /\u003e\n        \u003c/a\u003e\n        \u003ca href=\"http://hapijs.com\"\u003e\n            \u003cimg src=\"http://bit.ly/2lYPYPw\"\n                align=\"right\" alt=\"Hapijs logo\" width=\"75\" style=\"border:none;\" /\u003e\n        \u003c/a\u003e\n    \u003c/div\u003e\n\u003c/div\u003e\n\n# sequelize-module\n\nSequelize-module is a wrapper of [sequelize](http://docs.sequelizejs.com/) and [sequelize-typescript](https://github.com/RobinBuschmann/sequelize-typescript) for the Hapiness Framework.\n\n## Table of contents\n* [Using sequelize-module inside your Hapiness application](#using-sequelize-module-inside-your-hapiness-application)\n    * [`yarn` or `npm` it in your `package.json`](#yarn-or-npm-it-in-your-packagejson)\n    * [Installing peer dependencies](#installing-peer-dependencies)\n    * [Importing `SequelizeModule` from the library](#importing-sequelizemodule-from-the-library)\n* [Models](#models)\n    * [Defining a model](#defining-a-model)\n    * [Injecting a model](#injecting-a-model)\n* [`SequelizeClientService` functions](#sequelizeclientservice-functions)\n* [Mainteners](#maintainers)\n\n## Using sequelize-module inside your Hapiness application\n\n### `yarn` or `npm` it in your `package.json`\n```bash\n// Using NPM\n$ npm install --save @hapiness/core @hapiness/sequelize rxjs\n\n// Using Yarn\n$ yarn add @hapiness/core @hapiness/sequelize rxjs\n```\n\n### Installing peer dependencies\nAccording to `sequelize` documentation you will need to install at least one of these packages for sequelize-module to work:\n\n```bash\n# Using NPM\n$ npm install --save pg@6 pg-hstore #pg@7 is currently not supported\n$ npm install --save mysql2\n$ npm install --save sqlite3\n$ npm install --save tedious # MSSQL\n\n# Using Yarn\n$ yarn add pg pg-hstore\n$ yarn add mysql2\n$ yarn add sqlite3\n$ yarn add tedious # MSSQL\n```\n```javascript\n\"dependencies\": {\n    \"@hapiness/core\": \"^1.3.0\",\n    \"@hapiness/sequelize\": \"^1.0.0\",\n    \"rxjs\": \"^5.5.3\",\n    // + one of these\n    \"mysql2\": \"^1.5.1\",\n    \"pg\": \"^6.4.2\",\n    \"pg-hstore\": \"^2.3.2\",\n    \"sqlite3\": \"^3.1.13\",\n    \"tedious\": \"^2.1.5\"\n    //...\n}\n```\n\n### Importing `SequelizeModule` from the library\n\nThis module provide an Hapiness extension for Sequelize.\nTo use it, simply register it during the ```bootstrap``` step of your project and provide the ```SequelizeExt``` with its config\n\n```typescript\n@HapinessModule({\n    version: '1.0.0',\n    providers: [],\n    declarations: [],\n    imports: [SequelizeModule]\n})\nclass MyApp implements OnStart {\n    constructor() {}\n    onStart() {}\n}\n\nHapiness\n    .bootstrap(\n        MyApp,\n        [\n            /* ... */\n            SequelizeExt.setConfig(\n                {\n                    dialect: 'sqlite', // 'mysql'|'sqlite'|'postgres'|'mssql'\n                    username: 'username',\n                    password: 'password',\n                    database: 'database',\n                    storage: ':memory:' // Only for sqlite (path of the file or :memory:)\n                    // ...\n                }\n            )\n        ]\n    )\n    .catch(err =\u003e {\n        /* ... */\n    });\n```\n\n`SequelizeExt` needs an `Option` object so you can provide all the properties defined by [Sequelize](http://docs.sequelizejs.com/class/lib/sequelize.js~Sequelize.html#instance-constructor-constructor) with the minimum of the options below:\n```typescript\ninterface Options {\n    username: string;\n    password: string;\n    database: string;\n    dialect: 'mysql'|'sqlite'|'postgres'|'mssql';\n}\n```\n\n## Models\n\n### Defining a model\n\nSequelize-module uses `sequelize-typescript` so you can define your models with classes in the form of [sequelize-typescript models](https://github.com/RobinBuschmann/sequelize-typescript#model-definition). **However**, for your Models to be integreted in your Hapiness application you need to decorate it with `@TableModel`:\n\n```Typescript\nimport { Model, Table } from 'sequelize-typescript';\nimport { TableModel } from '@hapiness/sequelize';\n\n@TableModel()\n@Table\nexport class User extends Model\u003cUser\u003e { }\n```\n\n\u003e **NB**: You need to either name your model's file the name of your + `.ts` (here `user.ts`) or you need to export your model as default: `export default class User extends...`\n\n### Injecting a model\n\nTo Inject a Model in your application you just need to pass it to the array of `declarations` of your @`HapinessModule`.\n\n\u003e See examples directory for a basic working implementation. Run it with the command `npm run dev:watch`.\n\n## ```SequelizeClientService``` functions\n\nTo use sequelize, you need to inject inside your providers the ```SequelizeClientService```.\n\n```typescript\nclass FooProvider {\n\n    constructor(private _sequelize: SequelizeClientService) {}\n\n    bar(): Observable\u003cstring\u003e {\n    \treturn this._sequelize.instance.model('MyModel');\n    }\n}\n```\n\n`SequelizeClientService.instance` this will return you the sequelize client and you will be able to call on it every sequelize commands (see the reference [here](http://docs.sequelizejs.com/identifiers.html))\n\n[Back to top](#table-of-contents)\n\n## Maintainers\n\n\u003ctable\u003e\n    \u003ctr\u003e\n        \u003ctd colspan=\"5\" align=\"center\"\u003e\u003ca href=\"https://www.tadaweb.com\"\u003e\u003cimg src=\"http://bit.ly/2xHQkTi\" width=\"117\" alt=\"tadaweb\" /\u003e\u003c/a\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/Juneil\"\u003e\u003cimg src=\"https://avatars3.githubusercontent.com/u/6546204?v=3\u0026s=117\" width=\"117\"/\u003e\u003c/a\u003e\u003c/td\u003e\n        \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/antoinegomez\"\u003e\u003cimg src=\"https://avatars3.githubusercontent.com/u/997028?v=3\u0026s=117\" width=\"117\"/\u003e\u003c/a\u003e\u003c/td\u003e\n        \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/reptilbud\"\u003e\u003cimg src=\"https://avatars3.githubusercontent.com/u/6841511?v=3\u0026s=117\" width=\"117\"/\u003e\u003c/a\u003e\u003c/td\u003e\n        \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/njl07\"\u003e\u003cimg src=\"https://avatars3.githubusercontent.com/u/1673977?v=3\u0026s=117\" width=\"117\"/\u003e\u003c/a\u003e\u003c/td\u003e\n        \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/xmaIIoc\"\u003e\u003cimg src=\"https://avatars2.githubusercontent.com/u/1898461?s=117\u0026v=4\" width=\"117\"/\u003e\u003c/a\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/Juneil\"\u003eJulien Fauville\u003c/a\u003e\u003c/td\u003e\n        \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/antoinegomez\"\u003eAntoine Gomez\u003c/a\u003e\u003c/td\u003e\n        \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/reptilbud\"\u003eSébastien Ritz\u003c/a\u003e\u003c/td\u003e\n        \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/njl07\"\u003eNicolas Jessel\u003c/a\u003e\u003c/td\u003e\n        \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/xmaIIoc\"\u003eFlorent Bennani\u003c/a\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n\u003c/table\u003e\n\n[Back to top](#table-of-contents)\n\n## License\n\nCopyright (c) 2017 **Hapiness** Licensed under the [MIT license](https://github.com/hapinessjs/sequelize-module/blob/master/LICENSE.md).\n\n[Back to top](#table-of-contents)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhapinessjs%2Fsequelize-module","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhapinessjs%2Fsequelize-module","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhapinessjs%2Fsequelize-module/lists"}