Skip to content

How to query subset of data #5

@matthieunelmes

Description

@matthieunelmes

Apologies if this is outside the scope of this, but I'm attempting to port an application across from AngularJS to React and hoping there may be a solution here.

So my RTDB structure is set up as follows:

-customers
    -customer1
        -orders
            -key1:true
            -key2:true
            -key3:true
            
-orders
    -key1
    -key2
    -key3

Previously with AngularFire (for AngularJs) I could use the $extend functionality allowing me to return an array of Firebase objects with:

  var customerOrders = firebase.database().ref('customers/' + customerId + '/orders/');
  var orders = firebase.database().ref('orders');
  var OrdersList = $firebaseArray.$extend({
    $$added: function (snap) {
      return new Promise(function (resolve, reject) {
        $firebaseObject(orders.child(snap.key)).$loaded().then(function (orderData) {
          resolve(orderData);
        }).catch(reject);
      });
    }
  });
  return new OrdersList(customerOrders);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions