🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

debuggable-firebase

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

debuggable-firebase

Automatically select either the live or debugger version of the Firebase apps

Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
24
700%
Maintainers
1
Weekly downloads
 
Created
Source

Firestore Typescript Converter

By default, Firestore documents are untyped. This can be annoying when developing larger applications with lots of models.

This repository makes use of Firestore's converter feature to make the process easier for you without breaking the ideology behind it.

Installation

yarn install firestore-typescript-converter
npm install firestore-typescript-converter

Usage

First, create a converter for your model:

type User = {
    firstName: string
    lastName: string
}

const UserConverter = firestoreConverter<User>()

That's it! Now you can use the converter wherever you use Firestore. For example:

query(
    collection(getFirestore(), "profiles"),
    where("firstName", "==", "Bob")
).withConverter(ProfileConverter)

When calling data() on any of the documents resulting from this query, you will get a nice typed User object.

Including IDs

It might be useful to include the id field in the "data" of the document, to allow you to reference a single object rather than a separate id and data(). This package makes it easy!

The firestoreConverter function takes a single optional argument, includeID. If true, the ID will be included in the data (returning WithID<T> instead of just T)

const UserConverter = firestoreConverter<User>(true)

License

MIT license

FAQs

Package last updated on 29 Sep 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