Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

nested table in firebaseDatabase.set, how use?
Started by luch Mar 20 2020 06:06 AM

2 replies to this topic
firebasedatabase nested table
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

luch

[GLOBAL: userInfoPane.html]
luch
  • Observer

  • 10 posts
  • Corona SDK

Greetings,

Is possible use a nested table in 
firebaseDatabase.set?

Example:

local numday = 20 -- this always change
local today = "d" .. numday
local device_id = "device" .. system.getInfo( "deviceID" )


local oData = {
  [today] = {
    [device_id] = {
      time = tonumber( os.time( os.date("!*t") ) ),
      nome = USER_NAME,
      mail = USER_MAIL,
      vote = USER_VOTE
    }
  }
}


firebaseDatabase.set(
  "vote", oData, function( ev )
    if( ev.isError ) then
      native.showAlert( "Send.Err", json.encode( ev ) , {"Ok"} )
    else
      native.showAlert( "Send.Ok", json.encode( ev ) , {"Ok"} )
    end
  end
)

Best regards.



[TOPIC: post.html]
#2

Scott Harrison

[GLOBAL: userInfoPane.html]
Scott Harrison
  • Corona Geek

  • 1,851 posts
  • Enterprise

That should work

you could always do

firebaseDatabase.set(

  "vote/"..today, oData, function( ev )

    if( ev.isError ) then
      native.showAlert( "Send.Err", json.encode( ev ) , {"Ok"} )
    else
      native.showAlert( "Send.Ok", json.encode( ev ) , {"Ok"} )
    end
  end
)


  • luch likes this

[TOPIC: post.html]
#3

luch

[GLOBAL: userInfoPane.html]
luch
  • Observer

  • 10 posts
  • Corona SDK

@Scott Harrison, yes, work fine.
Thank you




[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: firebasedatabase, nested table