npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

iexpire

v1.0.1

Published

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 d

Downloads

8

Readme

About

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 use Example Test to see How does this package work

  • Easy to use

Alert

property "_id" must be included in the data because we use it as the container key

Installation

npm install iexpire
yarn add iexpire

How to use

const { MongoDbExpirer } = require("iexpire");
const iexpire = new MongoDbExpirer(<Modal>, {
<Options>
});

Options

{
  subtract: "",// He will subtract this period and then update it each time
  interval: "",//Here the Interval, when the period ends, it will subtract the number
  property: "",// property for expiration that will be updated
  delete: false,// If true, it will delete the document when the period ends
  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
}

Example

Example Test

const mongoose = require("mongoose");
const ms = require("ms");
mongoose.connect("<UrI>").then(async () => {
  const { MongoDbExpirer } = require("iexpire");
  const mongoose = require("mongoose");
  //Modal is the model that you want to create an expiration period
  const Schema = new mongoose.Schema({
    expiresAt: Number, //milliseconds
  });
  const Modal = mongoose.model("subscriptions", Schema); //Your model
  const iexpire = new MongoDbExpirer(Modal, {
    subtract: "1d",
    interval: "1s", //This is just an example. If the expiration period is in days, it is preferable to put it "1d" instead of "1s"
    property: "expiresAt",
    delete: true, // If true, it will delete the document when the period ends
    sync: "2s",
  });
  //This event if you get an error
  iexpire.on("error", (data) => {
    console.log(data);
  });
  //The data from which it was subtracted
  iexpire.on("subtract", (data) => {
    console.log(data);
  });
  //Here is the data that was deleted
  iexpire.on("delete", (data) => {
    console.log(data);
  });
  //And here it is when it expires
  iexpire.on("end", (data) => {
    console.log(data);
  });
  console.log("Connect To MongoDB Successfully");
  //There is no need to use this if you are taking the process seriously {This is just an example}
  Modal.create({
    expiresAt: ms("30d"),
  });
  //
});

Example Seriously

const mongoose = require("mongoose");
const ms = require("ms");
mongoose.connect("<UrI>").then(async () => {
  const { MongoDbExpirer } = require("iexpire");
  const mongoose = require("mongoose");
  //Modal is the model that you want to create an expiration period
  const Schema = new mongoose.Schema({
    expiresAt: Number,//milliseconds
  });
  const Modal = mongoose.model("subscriptions", Schema); //Your model
  const iexpire = new MongoDbExpirer(Modal, {
    subtract: "1d",
    interval: "1d",
    property: "expiresAt",
    delete: true, // If true, it will delete the document when the period ends
    sync: "2s",
  });
  //This event if you get an error
  iexpire.on("error", (data) => {
    console.log(data);
  });
  //The data from which it was subtracted
  iexpire.on("subtract", (data) => {
    console.log(data);
  });
  //Here is the data that was deleted
  iexpire.on("delete", (data) => {
    console.log(data);
  });
  //And here it is when it expires
  iexpire.on("end", (data) => {
    console.log(data);
  });
  console.log("Connect To MongoDB Successfully");
  });

Links

License