This document does not exist and will not appear in queries or snapshots, but identically structured document works

前端 未结 5 1578
鱼传尺愫
鱼传尺愫 2021-01-12 00:45

Preface: this question is already asked here but user gave up and gave solution to first answer. This question also differs in that I have two similar collection structures,

5条回答
  •  时光取名叫无心
    2021-01-12 01:24

    Not sure this will resolve your problem but did mine... the message in console: "This document does not exist, it will not appear in queries or snapshots" seems to appear if the document has only subcollections but no fields (I guess this is referred to as "virtual" document).

    I used set method to add dummy fields (json objects) on already existing "virtual" documents which made them discoverable by snapshots or queries. It did not overwrite/delete any subcollections of those documents. Fields could not be added via console.

    My code:

    var docRef = this.fsdb.collection('sessions')
    //do for all "virtual" docs in collection
    docRef.doc('mySession1').set({dummy: 'dummy'})
    
    docRef.onSnapshot(val => {
       var mySessionsArray: any [] = []
       val.forEach(myDoc => {
        mySessionsArray.push(myDoc.id)
      })
      console.log(mySessionsArray)
    })
    

    console: ["mySession1", "mySession2", "mySession3"]

    Disclaimer, not a programmer by trade :-)

提交回复
热议问题