1

I want to get data snapshot or valueChanges() from these two paths diretory/0GZfwgQqXRcJ3o2G23vClsEbPay1/files and directory/BgHYpuDpE3c7tRYuG2d8k0xHr2E2/files. However these paths will be dynamic and can be more than one. I dont want to apply for loop and subscribe to each path. I want single collection array with all these snapshots. How to do this using AngularFire Library?

Database Structure here

enter image description here

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
dasda
  • 13
  • 2

2 Answers2

1

Firebase Realtime Database always retrieves full nodes. While it is possible to filter what child nodes are returned with a query, there is no way to return a subset of the properties of each child nodes.

When you need this, it typically means that you should restructure your data to allow the use-case. For example in your JSON, you could have a top-level files child, which then the directory ID under it, and just the files for that directly. That way you could read all the files by reading /files.

The Firebase documentation covers this under avoid nesting data and flattening your data structures.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • https://stackoverflow.com/questions/43484811/firebase-multipath-fetch-data you are not getting my point. I want something like this in AngularFire.. call more than one path having no parent child relation. they can be in different parents as well.but to combine two paths and get their snapshots in one query – dasda Nov 09 '20 at 15:44
  • You can't do it in one query. My answer to the question you link fires two queries. You can do the same in AngularFire and join the two streams/observables. For an example of that, see https://stackoverflow.com/questions/46529904/angular-firebase-merge-two-observables-into-one – Frank van Puffelen Nov 09 '20 at 16:04
  • thanks Frank. any good resource from where I can learn queries and joins of firebase – dasda Nov 09 '20 at 16:07
  • I did a search for "angular fire merge observables" to find the above, so that'd be a good place to start I guess. – Frank van Puffelen Nov 09 '20 at 16:10
0

You can`t. Firebase does not support multi path queries. You can use the help of rsjx to join two observables and wait for their result to return and then join them. see this article for more info Is There Such A Thing As "Multi-Path Push" in Firebase Real-Time Datasbase?

Aliasgher Nooruddin
  • 534
  • 1
  • 6
  • 18