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

firehelper

v1.0.2

Published

A Node.js package designed for software testing, enabling the deletion of documents in Firestore based on flexible queries.

Downloads

10

Readme

Firehelper

A Node.js package designed for software testing, enabling the deletion of documents in Firestore based on flexible queries.

Installation

Clone the repository:

git clone https://github.com/yourusername/firehelper.git
cd firehelper

npm install

Configuration

Step 1: Set Up Firebase

  1. Go to the Firebase Console.
  2. Click on your project (or create a new project if you don't have one).
  3. Navigate to the Project Settings by clicking the gear icon.
  4. Under the Service Accounts tab, click on Generate New Private Key. This will download a JSON file to your computer. Save this file as serviceAccountKey.json.

Step 2: Add serviceAccountKey.json to Your Project

  1. Move the downloaded serviceAccountKey.json file to the src directory of your project.

Step 3: Update firebaseConfig.js

Make sure your firebaseConfig.js points to the correct location of the serviceAccountKey.json file:

const admin = require('firebase-admin');
const path = require('path');

const serviceAccount = require(path.join(__dirname, 'serviceAccountKey.json'));

admin.initializeApp({
  credential: admin.credential.cert(serviceAccount)
});

const db = admin.firestore();

module.exports = db;

Usage

You can use the package to delete documents in Firestore based on flexible queries.

Example Usage

const { deleteByQuery, deleteAllDocuments } = require('./src/index');

const run = async () => {
  try {
    // Example to delete by flexible query
    const resultByQuery = await deleteByQuery('[email protected]', 'notes', [
      { key: 'title', value: 'Some Title' },
      { key: 'userId', value: 'userId' }
    ]);
    console.log(resultByQuery);

    // Example to delete all documents
    const resultAllDocuments = await deleteAllDocuments('[email protected]', 'notes');
    console.log(resultAllDocuments);
  } catch (error) {
    console.error('Error:', error.message);
  }
};

run();

Functions

deleteByQuery(email, collectionName, queryFields)

Deletes documents based on a flexible query.

  • email: The user's email address.
  • collectionName: The name of the collection in Firestore.
  • queryFields: An array of query field objects. Each object should have a key and value. If value is 'userId', it will be replaced with the user's ID.

deleteAllDocuments(email, collectionName)

Deletes all documents for a user in a specified collection.

  • email: The user's email address.
  • collectionName: The name of the collection in Firestore.

License

This project is licensed under the MIT License.

Contact

Rocketskills - Github - [email protected]