{"id":14975755,"url":"https://github.com/lykmapipo/mongoose-kue","last_synced_at":"2025-04-04T17:15:33.843Z","repository":{"id":26895125,"uuid":"109789083","full_name":"lykmapipo/mongoose-kue","owner":"lykmapipo","description":"mongoose plugin to run mongoose schema methods in background","archived":false,"fork":false,"pushed_at":"2022-12-31T00:07:14.000Z","size":799,"stargazers_count":3,"open_issues_count":22,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-26T17:53:17.607Z","etag":null,"topics":["background","kue","later","mongoose","schema","worker"],"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/lykmapipo.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-07T05:02:58.000Z","updated_at":"2025-01-20T20:51:48.000Z","dependencies_parsed_at":"2023-01-14T05:32:01.418Z","dependency_job_id":null,"html_url":"https://github.com/lykmapipo/mongoose-kue","commit_stats":null,"previous_names":[],"tags_count":50,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lykmapipo%2Fmongoose-kue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lykmapipo%2Fmongoose-kue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lykmapipo%2Fmongoose-kue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lykmapipo%2Fmongoose-kue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lykmapipo","download_url":"https://codeload.github.com/lykmapipo/mongoose-kue/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247217220,"owners_count":20903009,"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":["background","kue","later","mongoose","schema","worker"],"created_at":"2024-09-24T13:52:29.734Z","updated_at":"2025-04-04T17:15:33.823Z","avatar_url":"https://github.com/lykmapipo.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mongoose-kue\n\n[![Build Status](https://travis-ci.org/lykmapipo/mongoose-kue.svg?branch=master)](https://travis-ci.org/lykmapipo/mongoose-kue)\n[![Dependency Status](https://img.shields.io/david/lykmapipo/mongoose-kue.svg?style=flat)](https://david-dm.org/lykmapipo/mongoose-kue)\n[![npm version](https://badge.fury.io/js/mongoose-kue.svg)](https://badge.fury.io/js/mongoose-kue)\n\nmongoose plugin to run mongoose schema methods in background.\n\n*Note!: It's highly advice to run worker(s) in separate process for better performance*\n\n## Requirements\n\n- NodeJS v10.0+\n\n## Install\n```sh\n$ npm install --save mongoose kue mongoose-kue\n```\n\n## Usage\n\n```js\nconst mongoose = require('mongoose');\nconst { Schema } = mongoose;\nconst { plugin: runInBackground, worker } = require('mongoose-kue');\n\n...\n\n/* queue sendEmail instance method to run in background */\nconst job =\n  user.runInBackground({ method: 'sendSMS', to: ['255714000111'] });\n\n/* queue sendEmail static method in background */\nconst job =\n  User.runInBackground({\n    method: 'sendEmail',\n    to: ['a@example.com', 'b@example.com']\n  });\n\n\n/* ADVICED: in separate process start processing */\nworker.start();\n\n...\n\n\n```\n\n\n## Options\n\n### Plugin\n```js\nconst { plugin: runInBackground } = require('mongoose-kue');\n\nmongoose.plugin(runInBackground, {\n  name: 'mongoose',\n  prefix: 'q',\n  MONGODB_URI: process.env.MONGODB_URI,\n  redis: (process.env.REDIS_URL || {\n    port: 1234,\n    host: '10.0.50.20',\n    auth: 'password',\n    db: 3\n  })\n});\n\n...\n\n```\n\n- `name` - Name of the worker queue to process background work,\n- `MONGODB_URI` - [Valid mongodb uri](https://mongoosejs.com/docs/index.html),\n- `attempts` - [Failure Attempts](https://github.com/Automattic/kue#failure-attempts)\n- `backoff` - [Failure Backoff](https://github.com/Automattic/kue#failure-backoff)\n- All applicable [kue](https://github.com/Automattic/kue#redis-connection-settings) connection settings\n\n\n### Worker\n\n*Note!: I highly recommend to run this in separate process*\n\n```js\nconst mongoose = require('mongoose');\nconst { worker } = require('mongoose-kue');\n\n/* load and register your models */\n\n...\n\n/* start worker queue to process in background */\nworker.start({\n  name: 'mongoose',\n  concurrency: 10,\n  prefix: 'q',\n  MONGODB_URI: process.env.MONGODB_URI,\n  redis: (process.env.REDIS_URL || {\n    port: 1234,\n    host: '10.0.50.20',\n    auth: 'password',\n    db: 3\n  })\n});\n``` \n\n- `name` - Name of the worker queue to process background work,\n- `MONGODB_URI` - [Valid mongodb uri](https://mongoosejs.com/docs/index.html),\n- `concurrency` - [Processing Concurrency](https://github.com/Automattic/kue#processing-concurrency). Default to 10,\n- `timeout` - [Graceful shutdown delay](https://github.com/Automattic/kue#graceful-shutdown),\n- All applicable [kue](https://github.com/Automattic/kue#redis-connection-settings) connection settings\n\n## Environment\n```js\nKUE_NAME=mongoose\nKUE_JOB_TYPES=mongoose\nKUE_TIMEOUT=5000\nKUE_CONCURRENCY=10\nKUE_MAX_ATTEMPTS=3\nKUE_PRIORITY=normal\nKUE_JOB_EVENTS=false\nKUE_REMOVE_ON_COMPLETE=true\nKUE_REDIS_URL=redis://127.0.0.1:3000\nKUE_HTTP_PORT=5000\nKUE_HTTP_USERNAME=kue\nKUE_HTTP_PASSWORD=kue\nREDIS_URL=redis://127.0.0.1:3000\n```\n\n\n## References\n- [mongoose](http://mongoosejs.com/docs/guide.html)\n- [kue](https://github.com/Automattic/kue)\n\n\n## Testing\n* Clone this repository\n\n* Install all development dependencies\n```sh\n$ npm install\n```\n* Then run test\n```sh\n$ npm test\n```\n\n## Contribute\nIt will be nice, if you open an issue first so that we can know what is going on, then, fork this repo and push in your ideas. Do not forget to add a bit of test(s) of what value you adding.\n\n## Licence\nThe MIT License (MIT)\n\nCopyright (c) lykmapipo \u0026 Contributors\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flykmapipo%2Fmongoose-kue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flykmapipo%2Fmongoose-kue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flykmapipo%2Fmongoose-kue/lists"}