{"id":18523594,"url":"https://github.com/mongoosejs/mongoose-async-hooks","last_synced_at":"2025-04-09T11:31:40.808Z","repository":{"id":57127910,"uuid":"132522446","full_name":"mongoosejs/mongoose-async-hooks","owner":"mongoosejs","description":"Node.js async hooks support for mongoose","archived":false,"fork":false,"pushed_at":"2024-05-06T21:22:00.000Z","size":21,"stargazers_count":3,"open_issues_count":3,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-24T05:13:41.775Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mongoosejs.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":"2018-05-07T22:20:50.000Z","updated_at":"2024-05-06T21:22:04.000Z","dependencies_parsed_at":"2024-05-06T22:29:52.328Z","dependency_job_id":"c2b6e1c9-f5e9-4aa9-92a7-d004e2a11e2b","html_url":"https://github.com/mongoosejs/mongoose-async-hooks","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongoosejs%2Fmongoose-async-hooks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongoosejs%2Fmongoose-async-hooks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongoosejs%2Fmongoose-async-hooks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongoosejs%2Fmongoose-async-hooks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mongoosejs","download_url":"https://codeload.github.com/mongoosejs/mongoose-async-hooks/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248031507,"owners_count":21036417,"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-06T17:36:24.689Z","updated_at":"2025-04-09T11:31:39.368Z","avatar_url":"https://github.com/mongoosejs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mongoose-async-hooks\n\n[Mongoose](http://mongoosejs.com/) plugin providing experimental support for [Node.js `async_hooks`](https://nodejs.org/api/async_hooks.html)\n\n[![Build Status](https://secure.travis-ci.org/mongoosejs/mongoose-async-hooks.png)](http://travis-ci.org/mongoosejs/mongoose-async-hooks)\n\n# Importing\n\n```javascript\n// Using Node.js `require()`\nconst mongooseAsyncHooks = require('@mongoosejs/async-hooks');\n\n// Using ES6 imports\nimport mongooseAsyncHooks from '@mongoosejs/async-hooks';\n```\n\n\n# Examples\n\n## It integrates with Node.js async hooks\n\n```javascript\nconst types = [];\nconst hooks = {\n  init: (asyncId, type) =\u003e {\n    types.push(type);\n  }\n};\n\nconst asyncHook = require('async_hooks').createHook(hooks);\n\nconst schema = new Schema({ name: String });\n\n// Add this plugin\nschema.plugin(mongooseAsyncHooks);\n\nconst MyModel = mongoose.model('MyModel', schema);\n\nasyncHook.enable();\n\nconst doc = new MyModel({ name: 'test' });\ndoc.save(function(error, doc) {\n  asyncHook.disable();\n\n  assert.ok(types.includes('mongoose.MyModel'));\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmongoosejs%2Fmongoose-async-hooks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmongoosejs%2Fmongoose-async-hooks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmongoosejs%2Fmongoose-async-hooks/lists"}