0

I have a order data that has user data and hotel data as references. Now i have the below code to get data

this.orderService.getOrders().subscribe(result => {
      this.orders = result.map(e => {
        return {
          id: e.payload.doc.id,
          uid: e.payload.doc.data()['uid'],
          vid: e.payload.doc.data()['vid'],
          grandTotal: e.payload.doc.data()['grandTotal'],
          status: e.payload.doc.data()['status'],
          paid:e.payload.doc.data()['paid'],
          time:e.payload.doc.data()['time']
        }
      });
    });

But uid and vid returns firestore document since it is a reference. But i tried like this

uid:e.payload.doc.data()['uid'].get().then(data=>{return res.data()}));

But it is returning a ZoneAwarePromise. How to get the value of the document?

OrderService.ts

 getOrders() {
    return this.db.collection('orders').snapshotChanges();
  }

1 Answers1

0

I will share with you a couple of documents for firestore best practices. Inside of this material you can find some queries samples and also information about firestore REST API.

Alva Santi
  • 75
  • 5