What strategy should I choose for getting all of 2-depth firebase data (if possible, not multiple queries)?
Let's say the data are memos of my-added-content and I want to get them by createdAt
.
In firebase database, the memo structure is here:
{
"memos": {
"uid1": {
"contentId1": {
"memoId123": {
"memoBody": "I want to write A",
"createdAt": 10,
...
},
"memoId213": {
"memoBody": "I want to write B",
"createdAt": 12,
...
}
},
"contentId2": {
"memoId312": {
"memoBody": "I want to write C",
"createdAt": 11,
...
},
"memoId321": {
"memoBody": "I want to write D",
"createdAt": 13,
...
}
}
}
}
}
What I want the result expected:
{
"memoId123": {
"createdAt": 10
...
},
"memoId312": {
"createdAt": 11
...
},
"memoId213": {
"createdAt": 12
...
},
"memoId321": {
"createdAt": 13
...
}
}
I thought it could be possible that brackets are used in string of ref:
firebase.database().ref('/memos/myuid/{contentId}').orderByChild('createdAt')
But this way is not worked.