Firestore: get document back after adding it / updating it without additional network calls

前端 未结 3 431
情话喂你
情话喂你 2020-12-17 19:58

Is it possible to get document back after adding it / updating it without additional network calls with Firestore, similar to MongoDB?

I find it stupid to first make

3条回答
  •  遥遥无期
    2020-12-17 20:23

    As you have probably seen in the documentation of the Node.js (and Javascript) SDKs, this is not possible, neither with the methods of a DocumentReference nor with the one of a CollectionReference.

    More precisely, the set() and update() methods of a DocumentReference both return a Promise containing void, while the CollectionReference's add() method returns a Promise containing a DocumentReference.


    Side Note (in line with answer from darrinm below): It is interesting to note that with the Firestore REST API, when you create a document, you get back (i.e. through the API endpoint response) a Document object.

提交回复
热议问题