Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

firestore-get-doc-wrapper

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

firestore-get-doc-wrapper

A powerful wrapper for Firestore's getDoc method with cache and retry functionality

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

What is this travesty?

It's simply a powerful wrapper around the getDoc method from firebase/firestore!

What can it do?

It currently supports automatic or configured caching and automatic retries. Basically, you can set a persistent cache time for a document and have it be enforced globally whenever you use getDocWrapper or you can set a one-time cache for one specific request, or you can completely bypass both!
You can also choose to retry a request a maximum amount of times, with or without a delay, or even only on specific Firestore errors!

Usage

const docData = await getDocWrapper(db, "path/to/your/document", {
    cacheOptions: {
	    enabled: true,
	    cacheTime: {
		    locked: true,
		    time: 70000,
		    bypassLockedTime: false
		},
		forceRefresh: false
    },
    retryOptions: {
	    enabled: true,
	    maxRetries: 7,
	    retryDelay: 5000,
	    retryOnErrorCode: ["deadline-exceeded"]
    }
}

Parameters

TO-DO but they're pretty self-explanatory, and there's a JSDoc for the function explaning the different cache types.

Troubleshooting

If getDocWrapper isn't retrying on specific errors make sure you are using them as they come from Firebase, i.e: lower-case letters and hyphens instead of upper-case letters and underscores. This can be easily implemented but currently there's no need to as I only built this library for personal use, if it starts to gain some traction, I'll be happy to do it!

Keywords

FAQs

Package last updated on 06 Apr 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc