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

unsubscribe

v0.0.1

Published

- Create a file `.npmrc` in the same directory as `package.json`

Downloads

5

Readme

#Unsubscribe This is a class that provides methods for unsubscribing contacts from a mailing list and storing the data in MongoDB.

Installation To use this class, you need to install the mongodb module from npm:

Usage To create an instance of the Unsubscribe class, you need to pass the MongoDB connection string and the database name as arguments:

npm install unsubscribe@latest

const unsubscribe = new Unsubscribe( "mongodb://localhost:27017", "myDatabase" );

The Unsubscribe class has the following methods:

storeSubscription(criteria: any, subscription: any): This method takes two arguments: criteria and subscription. The criteria argument is an object that specifies the query criteria for finding the document to update in the contacts collection. The subscription argument is a boolean value that indicates whether the contact is unsubscribed or not. This method updates the document with the subscription status and the date of the action. getMongoClient(): This method returns a MongoDB client object that is connected to the database. If the client is already connected, it returns the existing client. Otherwise, it creates a new client and connects to the database using the connection string provided in the constructor. updateMongoCollection(collectionName: any, criteria: any, document: any, dbName: any): This method takes four arguments: collectionName, criteria, document, and dbName. The collectionName argument is a string that specifies the name of the collection to update. The criteria argument is an object that specifies the query criteria for finding the document to update. The document argument is an object that specifies the fields and values to update in the document. The dbName argument is an optional string that specifies the name of the database to use. If not provided, it uses the database name provided in the constructor. This method updates the document using the MongoDB client returned by the getMongoClient() method. Example Here is an example of how to use the Unsubscribe class to unsubscribe a contact:

const unsubscribe = new Unsubscribe( "mongodb://localhost:27017", "myDatabase" );

// Assume we have a contact document with this structure: // { // _id: "123456789", // name: "John Doe", // email: "[email protected]", // isUnsubscribed: false, // subscribedDate: "2023-10-24T07:34:53.000Z" // }

// To unsubscribe this contact, we can use this code: unsubscribe.storeSubscription( { _id: "123456789" }, // criteria true // subscription );

// This will update the document with these fields: // { // _id: "123456789", // name: "John Doe", // email: "[email protected]", // isUnsubscribed: true, // unsubscribedDate: "2023-10-24T07:35:53.000Z" // current date // }