I have data in which I tried to follow Firebase's advice on a flat structure, so I don't pull more than I need. End result: I have quotes organized in such nodes:
quotes -> clientName -> quoteObject
quotObjects has a dateCreated value, and I want to be able to pull this data out like this (when, when I pull out one large list of all quotes for a specific page, I then use the object assignment to make one large array of objects to display):
const quotesRef = firebase.database().ref('quotes');
quotesRef.orderByChild('dateCreated').on('value', snapshot => {
});
Unfortunately, the value of dateCreated is more than one level, so the standard query does not work. I know that you can make a request for a deep path if you know the parent path, but in my case the parent clientName is always unique. Given this, is it possible to specify the type of the wildcard path? If so, how can I do this? Hooray!
Edit: With a sample database, sorry, it must have been more specific initially.
quotes
- ClientEmailOne
-UniqueQuoteID
- createdBy: ClientEmailOne
- dateCreated: 1479255005172
- email: "clientsEmail@example.com"
- ClientEmailTwo
-UniqueQuoteID
- createdBy: ClientEmailTwo
- dateCreated: 1479255005172
- email: "clientsEmail@example.com"
- ClientEmailThree
-UniqueQuoteID
- createdBy: ClientEmailThree
- dateCreated: 1479255005172
- email: "clientsEmail@example.com"
-UniqueQuoteID
- createdBy: ClientEmailThree
- dateCreated: 1479255005172
- email: "clientsEmail@example.com"
-UniqueQuoteID
- createdBy: ClientEmailThree
- dateCreated: 1479255005172
- email: "clientsEmail@example.com"
source
share