Firebase on android how to return only the node without children
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
This might be an odd question. However, I am running out of the free quota of my firebase database and before start paying for it, I want to optimize some of my firebase queries.
I was observing the firebase console where we can manage the database and I noticed that it only shows us the nodes on each level. To see the children we must click on the +
button (next to the node name) or at the node itself.
I believe this behaviour is designed to avoid requesting the whole database at once what would lead to a huge traffic and resource consumption. I also believe that firebase console was built on firebase public API, so it should be possible for us to implement the same behaviour.
My question is considering this following database:
{
"root":{
"node1":{
"childA":"a",
"childB":"b",
"childC":"c"
},
"node2":{
"childA":"2a",
"childB":"2b",
"childC":"2c"
},
"node3":{
"childA":"3a",
"childB":"3b",
"childC":"3c"
},
"node4":{
"childA":"4a",
"childB":"4b",
"childC":"4c"
},
"lululu":{
"childA":"1a",
"childB":"2b",
"childC":"3c"
},
"node1214":{
"childA":"1a",
"childB":"1b",
"childC":"1c"
},
"node10":{
"childA":"a",
"childB":"b",
"childC":"c"
}
}
}
How can I get the list of nodes under root
without their content (as a list for example like ["node1", "node2", "node3"...]
or as a proper Map
but without the child data (to reduce bandwidth usage)?
android firebase firebase-realtime-database
add a comment |
This might be an odd question. However, I am running out of the free quota of my firebase database and before start paying for it, I want to optimize some of my firebase queries.
I was observing the firebase console where we can manage the database and I noticed that it only shows us the nodes on each level. To see the children we must click on the +
button (next to the node name) or at the node itself.
I believe this behaviour is designed to avoid requesting the whole database at once what would lead to a huge traffic and resource consumption. I also believe that firebase console was built on firebase public API, so it should be possible for us to implement the same behaviour.
My question is considering this following database:
{
"root":{
"node1":{
"childA":"a",
"childB":"b",
"childC":"c"
},
"node2":{
"childA":"2a",
"childB":"2b",
"childC":"2c"
},
"node3":{
"childA":"3a",
"childB":"3b",
"childC":"3c"
},
"node4":{
"childA":"4a",
"childB":"4b",
"childC":"4c"
},
"lululu":{
"childA":"1a",
"childB":"2b",
"childC":"3c"
},
"node1214":{
"childA":"1a",
"childB":"1b",
"childC":"1c"
},
"node10":{
"childA":"a",
"childB":"b",
"childC":"c"
}
}
}
How can I get the list of nodes under root
without their content (as a list for example like ["node1", "node2", "node3"...]
or as a proper Map
but without the child data (to reduce bandwidth usage)?
android firebase firebase-realtime-database
add a comment |
This might be an odd question. However, I am running out of the free quota of my firebase database and before start paying for it, I want to optimize some of my firebase queries.
I was observing the firebase console where we can manage the database and I noticed that it only shows us the nodes on each level. To see the children we must click on the +
button (next to the node name) or at the node itself.
I believe this behaviour is designed to avoid requesting the whole database at once what would lead to a huge traffic and resource consumption. I also believe that firebase console was built on firebase public API, so it should be possible for us to implement the same behaviour.
My question is considering this following database:
{
"root":{
"node1":{
"childA":"a",
"childB":"b",
"childC":"c"
},
"node2":{
"childA":"2a",
"childB":"2b",
"childC":"2c"
},
"node3":{
"childA":"3a",
"childB":"3b",
"childC":"3c"
},
"node4":{
"childA":"4a",
"childB":"4b",
"childC":"4c"
},
"lululu":{
"childA":"1a",
"childB":"2b",
"childC":"3c"
},
"node1214":{
"childA":"1a",
"childB":"1b",
"childC":"1c"
},
"node10":{
"childA":"a",
"childB":"b",
"childC":"c"
}
}
}
How can I get the list of nodes under root
without their content (as a list for example like ["node1", "node2", "node3"...]
or as a proper Map
but without the child data (to reduce bandwidth usage)?
android firebase firebase-realtime-database
This might be an odd question. However, I am running out of the free quota of my firebase database and before start paying for it, I want to optimize some of my firebase queries.
I was observing the firebase console where we can manage the database and I noticed that it only shows us the nodes on each level. To see the children we must click on the +
button (next to the node name) or at the node itself.
I believe this behaviour is designed to avoid requesting the whole database at once what would lead to a huge traffic and resource consumption. I also believe that firebase console was built on firebase public API, so it should be possible for us to implement the same behaviour.
My question is considering this following database:
{
"root":{
"node1":{
"childA":"a",
"childB":"b",
"childC":"c"
},
"node2":{
"childA":"2a",
"childB":"2b",
"childC":"2c"
},
"node3":{
"childA":"3a",
"childB":"3b",
"childC":"3c"
},
"node4":{
"childA":"4a",
"childB":"4b",
"childC":"4c"
},
"lululu":{
"childA":"1a",
"childB":"2b",
"childC":"3c"
},
"node1214":{
"childA":"1a",
"childB":"1b",
"childC":"1c"
},
"node10":{
"childA":"a",
"childB":"b",
"childC":"c"
}
}
}
How can I get the list of nodes under root
without their content (as a list for example like ["node1", "node2", "node3"...]
or as a proper Map
but without the child data (to reduce bandwidth usage)?
android firebase firebase-realtime-database
android firebase firebase-realtime-database
edited Nov 16 '18 at 21:01
Reaz Murshed
13.7k84765
13.7k84765
asked Nov 16 '18 at 20:54
Rafael LimaRafael Lima
526421
526421
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
This is not possible with any of the mobile SDKs. It's only possible with the REST API using the shallow parameter.
add a comment |
In my opinion, the data structure should be as flat as possible to avoid nested data. You might consider restructuring your data as follows. You might consider taking a look at the best practices of storing and organizing your data in Firebase.
{
"root": {
"node1":"1",
"node2":"2",
"node3":"3"
},
"nodes" : {
"1": {
"childA":"a",
"childB":"b",
"childC":"c"
},
"2":{
"childA":"2a",
"childB":"2b",
"childC":"2c"
},
"3":{
"childA":"3a",
"childB":"3b",
"childC":"3c"
}
}
}
When you get the item, you get the children under the item as well. So avoid nesting your data. You might consider checking the answer here as well.
this model will solve my specific problem, but i wouldn't use it as a general idea... this way all queries will necessaryly require two requests... im looking at user branch and i do the pk of the user i still need to make two requests for getting user data... anyway thanks for the help
– Rafael Lima
Nov 16 '18 at 22:59
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53345237%2ffirebase-on-android-how-to-return-only-the-node-without-children%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
This is not possible with any of the mobile SDKs. It's only possible with the REST API using the shallow parameter.
add a comment |
This is not possible with any of the mobile SDKs. It's only possible with the REST API using the shallow parameter.
add a comment |
This is not possible with any of the mobile SDKs. It's only possible with the REST API using the shallow parameter.
This is not possible with any of the mobile SDKs. It's only possible with the REST API using the shallow parameter.
answered Nov 16 '18 at 21:00
Doug StevensonDoug Stevenson
85.1k10101120
85.1k10101120
add a comment |
add a comment |
In my opinion, the data structure should be as flat as possible to avoid nested data. You might consider restructuring your data as follows. You might consider taking a look at the best practices of storing and organizing your data in Firebase.
{
"root": {
"node1":"1",
"node2":"2",
"node3":"3"
},
"nodes" : {
"1": {
"childA":"a",
"childB":"b",
"childC":"c"
},
"2":{
"childA":"2a",
"childB":"2b",
"childC":"2c"
},
"3":{
"childA":"3a",
"childB":"3b",
"childC":"3c"
}
}
}
When you get the item, you get the children under the item as well. So avoid nesting your data. You might consider checking the answer here as well.
this model will solve my specific problem, but i wouldn't use it as a general idea... this way all queries will necessaryly require two requests... im looking at user branch and i do the pk of the user i still need to make two requests for getting user data... anyway thanks for the help
– Rafael Lima
Nov 16 '18 at 22:59
add a comment |
In my opinion, the data structure should be as flat as possible to avoid nested data. You might consider restructuring your data as follows. You might consider taking a look at the best practices of storing and organizing your data in Firebase.
{
"root": {
"node1":"1",
"node2":"2",
"node3":"3"
},
"nodes" : {
"1": {
"childA":"a",
"childB":"b",
"childC":"c"
},
"2":{
"childA":"2a",
"childB":"2b",
"childC":"2c"
},
"3":{
"childA":"3a",
"childB":"3b",
"childC":"3c"
}
}
}
When you get the item, you get the children under the item as well. So avoid nesting your data. You might consider checking the answer here as well.
this model will solve my specific problem, but i wouldn't use it as a general idea... this way all queries will necessaryly require two requests... im looking at user branch and i do the pk of the user i still need to make two requests for getting user data... anyway thanks for the help
– Rafael Lima
Nov 16 '18 at 22:59
add a comment |
In my opinion, the data structure should be as flat as possible to avoid nested data. You might consider restructuring your data as follows. You might consider taking a look at the best practices of storing and organizing your data in Firebase.
{
"root": {
"node1":"1",
"node2":"2",
"node3":"3"
},
"nodes" : {
"1": {
"childA":"a",
"childB":"b",
"childC":"c"
},
"2":{
"childA":"2a",
"childB":"2b",
"childC":"2c"
},
"3":{
"childA":"3a",
"childB":"3b",
"childC":"3c"
}
}
}
When you get the item, you get the children under the item as well. So avoid nesting your data. You might consider checking the answer here as well.
In my opinion, the data structure should be as flat as possible to avoid nested data. You might consider restructuring your data as follows. You might consider taking a look at the best practices of storing and organizing your data in Firebase.
{
"root": {
"node1":"1",
"node2":"2",
"node3":"3"
},
"nodes" : {
"1": {
"childA":"a",
"childB":"b",
"childC":"c"
},
"2":{
"childA":"2a",
"childB":"2b",
"childC":"2c"
},
"3":{
"childA":"3a",
"childB":"3b",
"childC":"3c"
}
}
}
When you get the item, you get the children under the item as well. So avoid nesting your data. You might consider checking the answer here as well.
answered Nov 16 '18 at 21:14
Reaz MurshedReaz Murshed
13.7k84765
13.7k84765
this model will solve my specific problem, but i wouldn't use it as a general idea... this way all queries will necessaryly require two requests... im looking at user branch and i do the pk of the user i still need to make two requests for getting user data... anyway thanks for the help
– Rafael Lima
Nov 16 '18 at 22:59
add a comment |
this model will solve my specific problem, but i wouldn't use it as a general idea... this way all queries will necessaryly require two requests... im looking at user branch and i do the pk of the user i still need to make two requests for getting user data... anyway thanks for the help
– Rafael Lima
Nov 16 '18 at 22:59
this model will solve my specific problem, but i wouldn't use it as a general idea... this way all queries will necessaryly require two requests... im looking at user branch and i do the pk of the user i still need to make two requests for getting user data... anyway thanks for the help
– Rafael Lima
Nov 16 '18 at 22:59
this model will solve my specific problem, but i wouldn't use it as a general idea... this way all queries will necessaryly require two requests... im looking at user branch and i do the pk of the user i still need to make two requests for getting user data... anyway thanks for the help
– Rafael Lima
Nov 16 '18 at 22:59
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53345237%2ffirebase-on-android-how-to-return-only-the-node-without-children%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown