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

firebase-firestore-extra

v1.1.1

Published

Augmentations and typings for firebase/firestore

Downloads

6

Readme

About

Cool stuff that speed up your work with Cloud Firestore Database.

If you want to contribute just create pull rquest.

Installation and requirements

Currently web sdk only (not yet for Node.js. Expect separate package).

Tested with "firebase": "7.2.0" (firebase skd should be also installed with npm i -S firebase)

Compiled with TypeScript 3.6.3

$ npm i -S firebase-firestore-extra

Active augmentations in TypeScript app (when using plain JavaScript it is enough to require('firebase-firestore-extra') ):

// Mandatory line, even if you are importing something using 'from' syntax
// In case of Angular app put it in main.ts
import 'firebase-firestore-extra';

// Then import required types, even in the same file as above import...
import { DocRef } from 'firebase-firestore-extra';

Examples

Some examples (you should be able to figure out everything on your own using typings and firestore documentation)

import { Doc, DocRef, ColRef, Query } from 'firebase-firestore-extra';
import * as firebase from 'firebase';

interface IData = Doc<{name: string, age: number}>

// configure firebase...
let db = fireStoreDb;

// Of course await inside async function only
let colRef: ColRef<IData> = db.collection('col') as ColRef<IData>;
let docRef: DocRef<IData> = colRef.doc('docId');

let typedList: IData[] = await colRef.xGet();
let typedObj:  IData   = await docRef.xGet();

let myObject: IData = {} as any;
let stop = docRef.xWatch(myObject, {otherOptions});
// You can deduce other options from typings
// Variable myObject will be synced with database document until stop() called
stop();

let myArray: IData = {} as any;
let stop = colRef.xWatch(myArray, {otherOptions});
// You can deduce other options from typings
// Array myObject will be synced with database documents list until stop() called
stop();

// You can also query with typings
colRef.where('name', '==', 'Nejm').limit(10).xWatch(myArray, {otherOptions});

// Firebase native options objects:
//
// onError handler
// firebase.firestore.GetOptions
// firebase.firestore.SnapshotOptions
// firebase.firestore.SnapshotListenOptions

// The only additional options provided by firestore-extra are hooks:
colRef.xWatch(myArray, {
    hooks: {
        afterAdded: handlerFunc // You can sound alarm if you received new document created later than Date.now()
        afterMofified: handlerFunction
        afterRemoved: handlerFunction
    }
});

// !!
// If handlerFunction will be method of some class remember to use bind

Documentation

Just check examples and typings.

For more advanced use cases please check firebase/firestore documentaion and find corresponding options when usign xGet and xWatch methods