Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Firebase: how get data?
Started by luch Mar 22 2020 04:03 AM

No replies to this topic
firebase select
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

luch

[GLOBAL: userInfoPane.html]
luch
  • Observer

  • 10 posts
  • Corona SDK

Greetings,

In firebase I have this db example:
 

{
	"fruits" : [
		"apple",
		"banana",
		"lemon",
		"orange",
	],
	"house" : {
		"id01" : { "fruit" :  1, "color" : 2 },
		"id02" : { "fruit" :  2, "color" : 4 },
		"id03" : { "fruit" :  3, "color" : 6 },
	},
	"color" : [
		{ "yellow" : {1,1,0} },
		{ "black"  : {0,0,0} },
		{ "red"    : {1,0,0} },
		{ "green"  : {0,1,1} }
	],
}

 

 

How proceed this?

I have a data "id01", and it contain: { "fruit" : 1, "color" : 2 },
How get?

fruits: banana

color: red, {1,0,0}





I am newbie in this case... Sorry.
This is?

 

firebaseDatabase.get(
	"house/id01" .. invite, function (ev)
		if(ev.isError) then
			label1.text = "Err\n[" .. json.encode( ev ) .. "]"
		else
			label1.text = "Ok\n[" .. json.encode( ev ) .. "]"
			local house = ev.data

			label2.text = "app_config\n[" .. json.encode( app_config ) .. "]"

			firebaseDatabase.get(
				"fruits/" .. house.fruit, function (ev)
					if(ev.isError) then
						label3.text = "Err\n[" .. json.encode( ev ) .. "]"
					else
						label3.text = "fruits\n[" .. json.encode( ev ) .. "]"
						local fruits = ev.data
						label4.text = "fruits[" .. fruits .. "]"
					end
				end
			end

			firebaseDatabase.get(
				"color/" .. house.color, function (ev)
					if(ev.isError) then
						label5.text = "Err\n[" .. json.encode( ev ) .. "]"
					else
						label5.text = "color\n[" .. json.encode( ev ) .. "]"
						local color = ev.data
						label6.text = "color[" .. color .. "]"
					end
				end
			end

		end
	end
)

 

 




[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: firebase, select