Keeps track of method calls from a firestore query instance
$ npm install firebase-firestore-query-sniffer firebase
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 //=> []
TODO: Add content
This project is licensed under the ISC License - see the LICENSE.md file for details