{"id":21988811,"url":"https://github.com/nealwp/smodg","last_synced_at":"2026-02-16T17:02:29.545Z","repository":{"id":143038148,"uuid":"614670242","full_name":"nealwp/smodg","owner":"nealwp","description":"Generate Sequelize models from TypeScript type definitions","archived":false,"fork":false,"pushed_at":"2025-03-16T17:23:30.000Z","size":156,"stargazers_count":2,"open_issues_count":7,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-10T08:14:56.524Z","etag":null,"topics":["cli","code-generation","orm-models","sequelize","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/nealwp.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-03-16T04:14:12.000Z","updated_at":"2023-09-17T03:13:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"7f6b8423-4354-4d35-8220-1c4ad57de57b","html_url":"https://github.com/nealwp/smodg","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/nealwp/smodg","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nealwp%2Fsmodg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nealwp%2Fsmodg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nealwp%2Fsmodg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nealwp%2Fsmodg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nealwp","download_url":"https://codeload.github.com/nealwp/smodg/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nealwp%2Fsmodg/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29513434,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-16T09:05:14.864Z","status":"ssl_error","status_checked_at":"2026-02-16T08:55:59.364Z","response_time":115,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["cli","code-generation","orm-models","sequelize","typescript"],"created_at":"2024-11-29T19:22:46.662Z","updated_at":"2026-02-16T17:02:29.532Z","avatar_url":"https://github.com/nealwp.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# smodg - Sequelize Model Generator \n\u003e Generate Sequelize models from TypeScript type definitions\n\n[![npm version](https://badgen.net/npm/v/smodg)](https://www.npmjs.com/package/smodg)\n![tests](https://github.com/nealwp/smodg/actions/workflows/test.yml/badge.svg)\n![build](https://github.com/nealwp/smodg/actions/workflows/build.yml/badge.svg)\n\n## Installation\n\n```bash\nnpm install -g smodg@latest\n```\nor\n```bash\nnpx smodg@latest \n```\n## Usage\n\n```\nUsage:\n\n    smodg [options] \u003cfilepath\u003e \n\nOptions:\n\n    --help, -h                   show help\n    --migration                  create an Umzug migration. default: false\n    --outputDir=PATH, -o PATH    model output directory, relative to current path. default: \"src/models\"         \n    --schema=NAME, -s NAME       specify a schema. default is no schema \n    --version, -v                print installed version\n```\n\n## Examples:\nCreate a model in `src/models`:\n```bash\nsmodg ./my-type-file.ts\n```\n\nCreate a model with a specific schema name:\n```bash\nsmodg --schema=my_schema ./my-type-file.ts\n```\n\nCreate a model and include a CREATE TABLE migration in `./src/migrations`:\n```bash\nsmodg --migration ./my-type-file.ts\n```\n\nCreate a model with a custom output path:\n```bash\n# do not prefix output dir with ./\nsmodg --outputDir=src/db-schema ./my-type-file.ts\n```\n## Features\n* Generates boilerplate Sequelize model in `./src/models/` that includes:\n    * imports from `sequelize-typescript` and `sequelize`\n    * `Attributes` and `ColumnOptions` interfaces\n    * table definition object with table name\n    * column definition object with column names and datatypes\n    * model definition with `@Table` and `@Column` decorators\n\n## Limitations\n* Currently only works with one type per file. Multiple type aliases in one file will not work.\n* Defaults properties of type `number` to `Sequelize.FLOAT`. All generated numeric column definitons need to be reviewed for accuracy.\n* Foreign keys and constraints must be added manually\n* `interface` is not supported yet\n\n## Example Output\n\n```typescript\n// my-custom-type.ts\nexport type UserAccount = {\n    name: string,\n    userName: string,\n    birthday: Date,\n    age: number,\n    isActive: boolean\n}\n```\n\n```bash\n# terminal command\nsmodg --schema=applicationAccess --migration ./my-custom-type.ts\n```\n\nThe above command will generate two files:\n\n```typescript\n// src/models/user-account.model.ts\nimport {\n    Column,\n    Table,\n    Model,\n    DataType,\n    CreatedAt,\n    UpdatedAt,\n    ForeignKey,\n    HasMany,\n} from 'sequelize-typescript';\n\nimport { UserAccount as UserAccountType } from '@_YOUR_TYPES'\nimport { ModelAttributeColumnOptions } from 'sequelize';\n\ninterface UserAccountCreationAttributes extends UserAccountType {}\n\ninterface UserAccountAttributes extends UserAccountCreationAttributes {\n    id: number;\n    createdBy: string;\n    createdDate: Date;\n    updatedBy: string;\n    updatedDate: Date;\n}\n\ntype UserAccountKeys = keyof UserAccountAttributes\n\ninterface ColumnOptions extends ModelAttributeColumnOptions {\n    field: string\n}\n\nexport const tableDefinition = {\n    tableName: 'user_account',\n    schema: 'application_access',\n}\n\nexport const columnDefinition: Record\u003cUserAccountKeys, ColumnOptions\u003e = {\n    id: {\n        field: \"id\",\n        type: DataType.INTEGER,\n        primaryKey: true,\n        autoIncrement: true,\n    },\n    name: {\n        field: 'name',\n        type: DataType.STRING\n    },\n    userName: {\n        field: 'user_name',\n        type: DataType.STRING\n    },\n    birthday: {\n        field: 'birthday',\n        type: DataType.DATE\n    },\n    age: {\n        field: 'age',\n        type: DataType.FLOAT\n    },\n    isActive: {\n        field: 'is_active',\n        type: DataType.BOOLEAN\n    },\n    createdBy: {\n        field: \"created_by\",\n        type: DataType.STRING,\n    },\n    createdDate: {\n        field: \"created_date\",\n        type: DataType.DATE,\n    },\n    updatedBy: {\n        field: \"updated_by\",\n        type: DataType.STRING,\n    },\n    updatedDate: {\n        field: \"updated_date\",\n        type: DataType.DATE,\n    },\n}\n\n@Table(tableDefinition)\nexport class UserAccount\nextends Model\u003cUserAccountAttributes, UserAccountCreationAttributes\u003e\nimplements UserAccountAttributes {\n    @Column(columnDefinition.id)\n    id!: number;\n\n    @Column(columnDefinition.name)\n    name!: string\n\n    @Column(columnDefinition.userName)\n    userName!: string\n\n    @Column(columnDefinition.birthday)\n    birthday!: Date\n\n    @Column(columnDefinition.age)\n    age!: number\n\n    @Column(columnDefinition.isActive)\n    isActive!: boolean\n\n    @Column(columnDefinition.createdBy)\n    createdBy!: string;\n\n    @CreatedAt\n    @Column(columnDefinition.createdDate)\n    createdDate!: Date;\n\n    @Column(columnDefinition.updatedBy)\n    updatedBy!: string;\n\n    @UpdatedAt\n    @Column(columnDefinition.updatedDate)\n    updatedDate!: Date;\n}\n```\n\n```typescript\n// src/migrations/2023.05.18T18.13.57-Create-Table-UserAccount.ts\nimport { DataType } from 'sequelize-typescript';\nimport type { Migration } from '../db';\n\nconst tableDefinition = {\n    tableName: 'user_account',\n    schema: 'application_access',\n}\n\nconst columnDefinition = {\n    id: {\n        field: \"id\",\n        type: DataType.INTEGER,\n        primaryKey: true,\n        autoIncrement: true,\n    },\n    name: {\n        field: 'name',\n        type: DataType.STRING\n    },\n    userName: {\n        field: 'user_name',\n        type: DataType.STRING\n    },\n    birthday: {\n        field: 'birthday',\n        type: DataType.DATE\n    },\n    age: {\n        field: 'age',\n        type: DataType.FLOAT\n    },\n    isActive: {\n        field: 'is_active',\n        type: DataType.BOOLEAN\n    },\n    createdBy: {\n        field: \"created_by\",\n        type: DataType.STRING,\n    },\n    createdDate: {\n        field: \"created_date\",\n        type: DataType.DATE,\n    },\n    updatedBy: {\n        field: \"updated_by\",\n        type: DataType.STRING,\n    },\n    updatedDate: {\n        field: \"updated_date\",\n        type: DataType.DATE,\n    },\n};\n\nexport const up: Migration = async ({ context: queryInterface }) =\u003e {\n    await queryInterface.createTable(tableDefinition, columnDefinition);\n};\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnealwp%2Fsmodg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnealwp%2Fsmodg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnealwp%2Fsmodg/lists"}