Firestore - Listen to specific field change?

How can I listen to a specific field change with firestore js sdk ?

In the documentation, they only seem to show how to listen for the whole document, if any of the "SF" field changes, it will trigger the callback.

.onSnapshot(function(doc) {
    console.log("Current data: ", doc &&;


You can't. All operations in Firestore are on an entire document.

This is also true for Cloud Functions Firestore triggers (you can only receive an entire document that's changed in some way).

If you need to narrow the scope of some data to retrieve from a document, place that in a document within a subcollection, and query for that document individually.

Just in case you want to ignore events in some fields, you can do something like:

export const yourCloudFunction = functions.firestore
    field('foo', 'REMOVED', (change, context) => {
      console.log('Will get here only if foo was removed');
      // ... Your implementation here

I created a gist of the field function here. Remember, it is not avoiding your function to run if changes happen in other fields, it will just not handle that over to you and return a resolved promise instead.

Listen for the document, then set a conditional on the field you're interesting in:

firebase.firestore().collection('Dictionaries').doc('Spanish').collection('Words').doc(word).collection('Pronunciations').doc('Castilian-female-IBM').onSnapshot(function(snapshot) {
                      if ( { // eliminates an error message
                        if ( === 2) {
                          if (audioFilesReady === 3) {
                    }, function(error) {

I'm listening for a document for a voice (Castilian-female-IBM), which contains an array of audio files, in webm and mp3 formats. When both of those audio files have come back asynchronously then === 2. This increments a conditional. When two more voices come back (Castilian-male-IBM and Latin_American-female-IBM) then audioFilesReady === 3 and the next function $scope.showNextWord() fires.

Just out of the box what I do is watching before and after with the before and after method

const clientDataBefore =;
console.log("Info database before ", clientDataBefore);

const clientDataAfter =;
console.log("Info database after ", clientDataAfter );

For example now you should compare the changes for a specific field and do some actions or just return it.

Some more about and here

Need Your Help

Test parameterization in similar to NUnit

c# .net unit-testing nunit

Are there any means in framework similar to the following features of NUnit?

How to change granularity level of undo in emacs evil-mode with undo-tree?

vim emacs emacs24 evil-mode

These are some awesome options: emacs-24, evil-mode (using vim bindings in emacs), and undo-tree.