{"id":16869577,"url":"https://github.com/diegorbaquero/sequelize-express-findbyid","last_synced_at":"2025-04-05T11:42:22.629Z","repository":{"id":66180562,"uuid":"108189182","full_name":"DiegoRBaquero/sequelize-express-findbyid","owner":"DiegoRBaquero","description":"Find by id using a sequelize model, returning 404 error if not found","archived":false,"fork":false,"pushed_at":"2020-04-30T19:41:10.000Z","size":20,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-03T16:04:48.590Z","etag":null,"topics":["express","expressjs","find","findbyid","node","nodejs","sequelize","sequelizejs"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/DiegoRBaquero.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}},"created_at":"2017-10-24T22:09:17.000Z","updated_at":"2020-04-30T19:41:03.000Z","dependencies_parsed_at":"2023-06-11T02:50:44.546Z","dependency_job_id":null,"html_url":"https://github.com/DiegoRBaquero/sequelize-express-findbyid","commit_stats":{"total_commits":19,"total_committers":2,"mean_commits":9.5,"dds":"0.052631578947368474","last_synced_commit":"6e9b44d1faaf056e90af72756c757af81d25daf8"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DiegoRBaquero%2Fsequelize-express-findbyid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DiegoRBaquero%2Fsequelize-express-findbyid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DiegoRBaquero%2Fsequelize-express-findbyid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DiegoRBaquero%2Fsequelize-express-findbyid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DiegoRBaquero","download_url":"https://codeload.github.com/DiegoRBaquero/sequelize-express-findbyid/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247332524,"owners_count":20921852,"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","expressjs","find","findbyid","node","nodejs","sequelize","sequelizejs"],"created_at":"2024-10-13T15:01:10.037Z","updated_at":"2025-04-05T11:42:22.603Z","avatar_url":"https://github.com/DiegoRBaquero.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sequelize-express-findbyid [![npm](https://img.shields.io/npm/v/sequelize-express-findbyid.svg?style=flat-square)]() [![npm](https://img.shields.io/npm/dm/sequelize-express-findbyid.svg?style=flat-square)]() [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg?style=flat-square)](https://standardjs.com) [![npm](https://img.shields.io/npm/l/sequelize-express-findbyid.svg?style=flat-square)](LICENSE)\nFind by id using a sequelize model, returning 404 error if not found\n\n## Install\n```sh\nnpm i -S sequelize-express-findbyid\nor\nnpm install --save sequelize-express-findbyid\n```\n\n## API\n\n##### `const sef = sequelize-express-findbyid (model[, primaryKey = 'id'])`\n\n## Usage\n\n```js\nconst sef = require(`sequelize-express-findbyid`)\nconst findById = sef(Model) // Primary key is 'id'\nconst findByOtherId = sef(Model, 'OtherId') // Primary key is 'OtherId'\n\nrouter.get('/:id', (req, res, next) =\u003e {\n  findById(req.params.id).then(result =\u003e res.send(result))\n    .catch(e =\u003e next(e))\n})\n```\n\n## Full await/async example inside express router\n\n```js\nconst express = require('express')\nconst sef = require(`sequelize-express-findbyid`)\n\nconst router = express.Router()\nconst db = require(`./db`) // Your sequelize models\nconst Model = db.ModelName // Your model\nconst findById = sef(Model) // Primary key is 'id'\n\nrouter.get('/:id', async (req, res, next) =\u003e {\n  res.send(await findById(req.params.id))\n})\n```\n\n## Related\n\n- [express-route-autoloader](https://github.com/DiegoRBaquero/express-route-autoloader)\n- [express-sequelize-crud-router](https://github.com/DiegoRBaquero/express-sequelize-crud-router)\n- [express-debug-async-wrap](https://github.com/DiegoRBaquero/express-debug-async-wrap)\n\n\n## License\nMIT Copyright © [Diego Rodríguez Baquero](https://diegorbaquero.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiegorbaquero%2Fsequelize-express-findbyid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdiegorbaquero%2Fsequelize-express-findbyid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiegorbaquero%2Fsequelize-express-findbyid/lists"}