{"id":18273410,"url":"https://github.com/blinet/iexpire","last_synced_at":"2026-05-19T06:03:00.797Z","repository":{"id":53516743,"uuid":"521432092","full_name":"blinet/iexpire","owner":"blinet","description":" Adding an expiration period in the form of a count and you can also update the duration in your model and here it will automatically synchronize the new period And when this period expires, the event will be issued, this package currently supports these database systems. MongoDB How this package works: You will create a connection to the model with data that you want to create for an expiration period, and note that the package only supports milliseconds Then it will create a dummy container within the process that has a duration for each object, and it will subtract the period that you put within the option every time the session of the intervel period that you put into the option ends.  I do not know my explanation is understandable or not, but this package you run only once on the model you want to create an expiration period and you do not need to create a new one every time","archived":false,"fork":false,"pushed_at":"2022-08-06T23:00:16.000Z","size":63,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-05-01T18:30:07.176Z","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/blinet.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}},"created_at":"2022-08-04T22:26:48.000Z","updated_at":"2022-08-04T23:30:48.000Z","dependencies_parsed_at":"2022-09-02T23:21:45.864Z","dependency_job_id":null,"html_url":"https://github.com/blinet/iexpire","commit_stats":null,"previous_names":["4i8/iexpire"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blinet%2Fiexpire","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blinet%2Fiexpire/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blinet%2Fiexpire/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blinet%2Fiexpire/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/blinet","download_url":"https://codeload.github.com/blinet/iexpire/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247974584,"owners_count":21026742,"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-05T12:06:19.743Z","updated_at":"2026-05-19T06:03:00.731Z","avatar_url":"https://github.com/blinet.png","language":"JavaScript","funding_links":["https://paypal.me/arosteam?country.x=SA\u0026locale.x=ar_EG"],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003cp\u003e\n \u003ca href=\"https://www.npmjs.com/package/iexpire\"\u003e\u003cimg  src=\"https://github.com/4i8/iexpire/blob/master/logo/iexpire.png\" width=\"400\" alt=\"iexpire\" /\u003e\u003c/a\u003e\n  \u003c/p\u003e\n  \u003cp\u003e\n \u003ca href=\"https://github.com/arosteam\"\u003e\u003cimg src=\"https://img.shields.io/static/v1?label=powered%20by\u0026message=Aros\u0026color=000636\u0026style=for-the-badge\u0026logo=Windows%20Terminal\u0026logoColor=fff\"/\u003e\u003c/a\u003e\n \u003ca href=\"https://www.npmjs.com/package/iexpire\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/iexpire.svg?style=for-the-badge\" alt=\"NPM version\" /\u003e\u003c/a\u003e\n \u003ca href=\"https://www.npmjs.com/package/iexpire\"\u003e\u003cimg src=\"https://img.shields.io/npm/dt/iexpire.svg?maxAge=3600\u0026style=for-the-badge\" alt=\"NPM downloads\" /\u003e\u003c/a\u003e\n     \u003ca href=\"https://paypal.me/arosteam?country.x=SA\u0026locale.x=ar_EG\"\u003e\u003cimg src=\"https://img.shields.io/badge/-donate-blue.svg?logo=paypal\u0026style=for-the-badge\" alt=\"NPM downloads\" /\u003e\u003c/a\u003e\n\n  \u003c/p\u003e\n  \n\u003c/div\u003e\n\n# **About**\n\nAdding an expiration period in the form of a count and you can also update the duration in your model and here it will automatically synchronize the new period\nAnd when this period expires, the event will be issued, this package currently supports these database systems.\nMongoDB\nHow this package works: You will create a connection to the model with data that you want to create for an expiration period, and note that the package only supports milliseconds\nThen it will create a dummy container within the process that has a duration for each object, and it will subtract the period that you put within the [option](#options) every time the session of the intervel period that you put into the [option](#options) ends.\n\nI do not know my explanation is understandable or not, but this package you run only once on the model you want to create an expiration period and you do not need to create a new one every time\nuse [Example Test](#example) to see How does this package work\n\n- Easy to use\n\n# **Alert**\n\nproperty \"\\_id\" must be included in the data because we use it as the container key\n\n# **Installation**\n\n```sh-session\nnpm install iexpire\nyarn add iexpire\n```\n\n# **How to use**\n\n```js\nconst { MongoDbExpirer } = require(\"iexpire\");\nconst iexpire = new MongoDbExpirer(\u003cModal\u003e, {\n\u003cOptions\u003e\n});\n```\n\n# **Options**\n\n```js\n{\n  subtract: \"\",// He will subtract this period and then update it each time\n  interval: \"\",//Here the Interval, when the period ends, it will subtract the number\n  property: \"\",// property for expiration that will be updated\n  delete: false,// If true, it will delete the document when the period ends\n  sync: \"2s\",//Here it checks if there is new data with a new id, and if it finds new data, it will create a new container for it with a different expiration period\n}\n```\n\n# **Example**\n\n### **Example Test**\n\n```js\nconst mongoose = require(\"mongoose\");\nconst ms = require(\"ms\");\nmongoose.connect(\"\u003cUrI\u003e\").then(async () =\u003e {\n  const { MongoDbExpirer } = require(\"iexpire\");\n  const mongoose = require(\"mongoose\");\n  //Modal is the model that you want to create an expiration period\n  const Schema = new mongoose.Schema({\n    expiresAt: Number, //milliseconds\n  });\n  const Modal = mongoose.model(\"subscriptions\", Schema); //Your model\n  const iexpire = new MongoDbExpirer(Modal, {\n    subtract: \"1d\",\n    interval: \"1s\", //This is just an example. If the expiration period is in days, it is preferable to put it \"1d\" instead of \"1s\"\n    property: \"expiresAt\",\n    delete: true, // If true, it will delete the document when the period ends\n    sync: \"2s\",\n  });\n  //This event if you get an error\n  iexpire.on(\"error\", (data) =\u003e {\n    console.log(data);\n  });\n  //The data from which it was subtracted\n  iexpire.on(\"subtract\", (data) =\u003e {\n    console.log(data);\n  });\n  //Here is the data that was deleted\n  iexpire.on(\"delete\", (data) =\u003e {\n    console.log(data);\n  });\n  //And here it is when it expires\n  iexpire.on(\"end\", (data) =\u003e {\n    console.log(data);\n  });\n  console.log(\"Connect To MongoDB Successfully\");\n  //There is no need to use this if you are taking the process seriously {This is just an example}\n  Modal.create({\n    expiresAt: ms(\"30d\"),\n  });\n  //\n});\n```\n\n### **Example Seriously**\n\n```js\nconst mongoose = require(\"mongoose\");\nconst ms = require(\"ms\");\nmongoose.connect(\"\u003cUrI\u003e\").then(async () =\u003e {\n  const { MongoDbExpirer } = require(\"iexpire\");\n  const mongoose = require(\"mongoose\");\n  //Modal is the model that you want to create an expiration period\n  const Schema = new mongoose.Schema({\n    expiresAt: Number,//milliseconds\n  });\n  const Modal = mongoose.model(\"subscriptions\", Schema); //Your model\n  const iexpire = new MongoDbExpirer(Modal, {\n    subtract: \"1d\",\n    interval: \"1d\",\n    property: \"expiresAt\",\n    delete: true, // If true, it will delete the document when the period ends\n    sync: \"2s\",\n  });\n  //This event if you get an error\n  iexpire.on(\"error\", (data) =\u003e {\n    console.log(data);\n  });\n  //The data from which it was subtracted\n  iexpire.on(\"subtract\", (data) =\u003e {\n    console.log(data);\n  });\n  //Here is the data that was deleted\n  iexpire.on(\"delete\", (data) =\u003e {\n    console.log(data);\n  });\n  //And here it is when it expires\n  iexpire.on(\"end\", (data) =\u003e {\n    console.log(data);\n  });\n  console.log(\"Connect To MongoDB Successfully\");\n  });\n```\n\n## Links\n\n- [Twiter](https://twitter.com/onlyarth)\n- [Github](https://github.com/4i8)\n\n## License\n\n- [Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblinet%2Fiexpire","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblinet%2Fiexpire","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblinet%2Fiexpire/lists"}