Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Studio Chat / json question

Author
Message
TamBam
12
Years of Service
User Offline
Joined: 29th Nov 2011
Location: India
Posted: 5th Oct 2020 22:00
i have a value on firebase suppose x=10 whrn i call http request its give me the perfect result but if i want to change the value of x then its create an extra key and the new x value created under the extra key. any one can solve it for me. thankyou
Dybing
12
Years of Service
User Offline
Joined: 12th Sep 2011
Location: Bergen, Norway
Posted: 23rd Oct 2020 04:01
You need to reference the key child-node to update.

Never used Firebase with AppGameKit, but work with it daily in Go. The code example below should be pretty easy to follow:



Of course, the AppGameKit syntax will be different. The important bits being:

ref := c.NewRef("tenants").Child(tID).Child("smsOverview")

This sets the node to be updated, where tID is the customer ID, the full Firebase path would look something like "tenants/1234/smsOverview/"

if err := ref.Update(ctx, map[string]interface{}{
"available": smsNew,

This sets the "available" node (or variable-name if you wish) under ""tenants/1234/smsOverview/" to its new value. The ctx variable is the context (connection, thread etc - most of it auto-managed in Go) and the map[string]interface{} is merely telling the type of key and value(s) will be inserted/updated. The [string] part is the "available" variable-name, the interface{} part is a type agnostic method which in this case will default to the int type of the "smsNew" value.

Login to post a reply

Server time is: 2024-04-18 18:46:20
Your offset time is: 2024-04-18 18:46:20