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 🙏

© 2026 – Pkg Stats / Ryan Hefner

swallowstore

v0.2.8

Published

A flexible easy to use Google Cloud Firestore API Wrapper class for Node.JS

Readme

Swallowstore

npm version NPM GitHub file size GitHub GitHub

A flexible easy to use Google Cloud Firestore API Wrapper class for Node.JS

Installation

npm install swallowstore

import * as swallowInstance from "swallowstore";

Sample Usage

const swallowInstance = require('swallowstore');

//swallowstore initialize with firestore config
swallowInstance.initialize({
    databaseURL: "https://my-first-project.com",
    projectId: "my-first-project",
})

// Get all users
swallowInstance.findAll('users').then(response => {
  console.log(response);
});

Available Methods: findById(), findOne(), findAll(), saveAndUpdate(), paginator(), delete()

API Reference

.initialize(firebaseConfig: object)

Set collection firebase Config.

Parameters:

  • object firebase config setting

    //swallowstore initialize with firestore config
    swallowInstance.initialize({
        databaseURL: "https://my-first-project.com",
        projectId: "my-first-project",
    })
.findById(collectionName: string, id: string ): Promise<Document[]>

Get One document in a collection by ID.

Parameters:

  • id The document ID / ids The document IDs

Returns:

  • A Document object or null

Sample Code:

// Get user by id 
swallowInstance.findById('users', '5ixWj00cZYDirdz9CCJd').then(response => {
    console.log("users with id '5ixWj00cZYDirdz9CCJd' detail:", response);
});

// Get user by ids
swallowInstance.findById('users', ['0Qq4GEfXPsc2ixvDZv8MFEcu2ek1', '0Qq4GEfXPsc2ixvDZv8MFEcu2ek1']).then(response => {
    console.log("users with ids '['0Qq4GEfXPsc2ixvDZv8MFEcu2ek1', '0Qq4GEfXPsc2ixvDZv8MFEcu2ek1']' detail:", response);
});
.findOne(collectionName: string, { conditions: Array<Condition> = null } ): Promise<Document[]>

Get One document in a collection by ID or by conditions.

Parameters:

  • conditions Array of conditions
  • id The document ID

Returns:

  • A Document object or null

Sample Code:


// Get user by id
swallowInstance.findOne('users', { id: '5ixWj00cZYDirdz9CCJd' }).then(response => {
    console.log("users with id '5ixWj00cZYDirdz9CCJd' detail:", response);
});

// Get user by condition(s)
const conditions = {
    'where': [
        ['email', '==', '[email protected]']
        ['password', '==', 'password']
    ]
};

swallowInstance.findOne('users', conditions).then(response => {
    console.log("user:", response);
});
.saveAndUpdate(collectionName: string, data: Object, id: String ): Promise<ResultData>

Add / Update a document.

Parameters:

  • data A document object
  • id The document ID

Returns:

  • ResultData object or null

Sample Code:

// Add a user with auto-generated ID
const userObject = {
    name: 'Kat',
    email: '[email protected]',
    gender: 'female'
};

swallowInstance.saveAndUpdate('users', userObject).then(response => {
    console.log("Add Result (auto-generated ID):", response);
});
// response { node_id: 'BQFNY9pQDhZOarvmoMSB' }

// Add a user with custom ID
const userObject = {
    node_id: 'BQFNY9pQDhZOarvmoMSB',
    name: 'Gary',
    email: '[email protected]',
    gender: 'male'
};

swallowInstance.saveAndUpdate('users', userObject).then(response => {
    console.log("Add Result (custom ID):", response);
});
// response { node_id: 'BQFNY9pQDhZOarvmoMSB' }


// Update a user with ID
swallowInstance.saveAndUpdate('users', userObject, 'BQFNY9pQDhZOarvmoMSB').then(response => {
    console.log("Updated Result:", response);
});
// response { node_id: 'BQFNY9pQDhZOarvmoMSB' }
.findAll(collectionName: string, { conditions: Array<Condition> = null, orderBy: Array<OrderBy> = null, limit: number = null } ): Promise<Document[]>

Get document in a collection.

Parameters:

  • conditions Array of conditions
  • orderBy Field name to order by
  • limit Number of documents to retrieve || default is 20

Returns:

  • Array of Document object

Sample Code:


// Get all users
swallowInstance.findAll('users').then(response => {
    console.log("All users: ", response);
});

// Get all users by condition(s)
const conditions = {
    'where': [
        ['age', '>=', 20]
        ['likes', '>=', 200]
    ],
    'limit': 5
};

swallowInstance.findAll('users', conditions).then(response => {
    console.log("All users with age >= '20' & likes >= '200', limit '5':", response);
});
.paginator(collectionName: string): paginatorDocument{}

Get paginate document in a collection.

Parameters:

  • conditions Array of conditions
  • orderBy Field name to order by
  • limit Number of documents to retrieve || default is 20

Returns:

  • Array of Document object

Sample Code:


// Get all users
let paginateInit;
paginateInit = swallowInstance.paginator('users');
paginateInit.params({'limit': 2, 'orderBy': 'full_name'}).then(({data}) => {
    console.log(data);
});
    
// Get the next index of user collection by condition(s)
paginateInit.next().then(({data}) => {
    console.log("next users collection: ",data);
});

// Get the previous index of user collection by condition(s)
paginateInit.previous().then(({data}) => {
    console.log("previous users collection: ",data);
});
delete(collectionName: string, id: string): Promise<ResultData>

Delete a document

Parameters:

  • id The document ID

Returns:

  • ResultData object or null

Sample Code:

// Delete a user by ID
swallowInstance.delete('users', {'id' : 'HnjIzeysNmi4DLL2tFUJ'}).then((res) => {
    console.log("Delete Result:", result);
});