firebase realtime database to update an entry after filter on list

101 views
Skip to first unread message

Vik

unread,
Sep 18, 2018, 11:53:02 PM9/18/18
to fireba...@googlegroups.com

The data in the realtime db is structure like below:

"orders" : {
    "-LM5p4tl7Og_PMJOspZ-" : {
      "customer" : {
        "_name" : "Vik Kumar",
        "_uid" : "oSEYj0zrkhPCk9r7uwyOOkHcqe53"
      },
      "order" : {
        "_orderNumber" : "VikKumar-26954",
        "_orderStatus" : "Pending",
        "_orderTotal" : 500,
      }
    },
    "-LM5s1wRCvqWA1vsZONy" : {
      "customer" : {
        "_name" : "Vik Kumar",
        "_uid" : "oSEYj0zrkhPCk9r7uwyOOkHcqe53"
      },
      "order" : {
        "_orderNumber" : "VikKumar-11423",
        "_orderStatus" : "Pending",
        "_orderTotal" : 500,
      }
    },
    "-LM5sOHzjLeqFGFleMxq" : {
      "customer" : {
        "_name" : "Vik Kumar",
        "_uid" : "oSEYj0zrkhPCk9r7uwyOOkHcqe53"
      },
      "order" : {
        "_orderNumber" : "VikKumar-63772",
        "_orderStatus" : "Pending",
        "_orderTotal" : 500,
      }
    }
}

I am using angularfire2 in my ionic app and filtering few orders as below:

getPendingOrders(dateStr:string){
    return new Promise((resolve, reject) =>
      {
        this.db.list('orders',
                     ref =>  ref.orderByChild("order/_date").equalTo(dateStr)
       ).valueChanges().subscribe(
        res => {
          resolve(res)
        },
        err => {
          console.log(err)
          reject(err)
        }
      )
      })
  }

The above query gives me the response as below

[{"customer": {}, "order": {}}, {"customer": {}, "order": {}}]

I can render it in UI just fine and i want the end user to be able to update the value of property "_orderStatus". The trouble is the way i queried the data i have lost the keys to identify a particular object to update it. Please advise

Thankx and Regards

Vik
Photographer
http://www.viksphotography.com

Kiana McNellis

unread,
Sep 19, 2018, 6:49:13 PM9/19/18
to fireba...@googlegroups.com

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/CAO5%2Bkz9L2brTFk9%3DWhPbzks%2BWR59_zODFphogaeNdmrv4nx7iQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages