firebase-firestore-query-sniffer
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

Firebase Firestore Query Sniffer

npm version Build Status

Keeps track of method calls from a firestore query instance

Table of contents

  1. Install
  2. Usage
  3. Contributing
  4. License

Install

$ npm install  firebase-firestore-query-sniffer firebase

Usage

Call createQuerySniffer with a firestore CollectionReference as parameter:

import { createQuerySniffer } from 'firebase-firestore-query-sniffer'
import firebase from 'firebase/app'
import 'firebase/firestore'

// initialize firebase
const app = firebase.initializeApp({...})
const db = app.firestore()

const query = createQuerySniffer(db.collection('collection'))
	.where('field', '==', 'value')

query.queryTrace
//=> [{ method: 'where', args: [ 'field', '==', 'value' ] }]

Accepts Query as parameter:

const query = createQuerySniffer(db.collectionGroup('collection'))

Every chainable method call returns a cloned copy of itself, just like what firestore query does:

// ...
const query = createQuerySniffer(db.collection('collection'))
const query2 = query.where('field', '==', 'value')

query.queryTrace //=> []
query2.queryTrace //=> [{ method: 'where', args: [ 'field', '==', 'value' ] }]

Method calls before it was transformed are not included traced:

const query = createQuerySniffer(
  db.collection('collection').where('field', '==', 'value')
)

query.queryTrace //=> []

Contributing

TODO: Add content

License

This project is licensed under the ISC License - see the LICENSE.md file for details

Readme

Keywords

none

Package Sidebar

Install

npm i firebase-firestore-query-sniffer

Weekly Downloads

2

Version

0.1.1

License

ISC

Unpacked Size

6.17 kB

Total Files

5

Last publish

Collaborators

  • virnont