I have created a custom table in my NoSql database explorer. This table contains general game and configuration data that I want to download to the client.
I am looking through the API and forums but cannot find how this data is queried.
I am using the Unity 5 SDK.
Thanks
Best Answer
G
Greg Quinn
said
almost 7 years ago
Thanks for all the help, I found the following code on the forums that uses LogEventRequest to query any event from the Unity3D client...
new LogEventRequest().SetEventKey("GET_RACE_DATA")
.SetEventAttribute("TRACK", "Track1")
.Send(r =>
{
if(r.HasErrors)
Debug.LogError("Error getting GET_RACE_DATA : " + r.Errors.GetString("DETAILS"));
else
{
var gsData = new GSData(r.ScriptData);
object[] list = gsData.GetObjectList("fastestRaceData").ToArray();
foreach (var l in list)
{
var dic = (Dictionary<string, object>)l;
foreach(var key in dic.Keys)
Debug.Log("key = " + key.ToString());
}
}
});
Have a look at SparkCursor. It could be a good place to start.
G
Greg Quinn
said
almost 7 years ago
How do I access that from the Unity client API? I only see SparkCursor as CloudCode.
A
Ayyappa R
said
almost 7 years ago
Yes Spark API is cloud API.
I see only possibility passing via Cloud code trough events. I mean fetch the results in cloud code and send as result for an event api call.
G
Greg Quinn
said
almost 7 years ago
Do you have an example of how to call these cloud code events from the client?
I've looked everywhere but nothing in the docs explains how to do this.
Thanks
A
Ayyappa R
said
almost 7 years ago
Hi,
To be frank I didn't try on this much as remove call on collection was not working earlier. You can refer to previous post on the problem started by Luis i guess. Sadly till now there was no response from GS team on that.
However,
I had a quick test as not having enough time currently, sorry if its not much clear enough, but i'm sure it might help you for sure.
var loginTime = Date.now();
var playerId = Spark.getPlayer().getPlayerId();
var playerName = Spark.getPlayer().getDisplayName();
//For saving
var playerLoginDataCollection = Spark.runtimeCollection('PlayerLoginDetails');
//For Query
var findQueryResult = playerLoginDataCollection.find({"playerId" : playerId});
Spark.setScriptData("findQueryResult", findQueryResult); //For debugging in Test harness
//For Removing entry
var removeQueryResult = playerLoginDataCollection.remove({"playerId" : playerId});
Spark.setScriptData("removeQueryResult", removeQueryResult);//For debugging in Test harness
//For Saving
playerLoginDataCollection.save({"playerId":playerId ,"playerName":playerName, "loginTime":loginTime});
Let me know if I can help you out.
Btw, the above is a cloud code i attached to an event. Just create an event with the required details and get the data by Spark.getData().ATTRIBUTE_NAME and you can save the details in the corresponding cloud script similar to above what I did.
Thanks,
VoxelBusters.com
@voxelbusters
G
Greg Quinn
said
almost 7 years ago
Answer
Thanks for all the help, I found the following code on the forums that uses LogEventRequest to query any event from the Unity3D client...
new LogEventRequest().SetEventKey("GET_RACE_DATA")
.SetEventAttribute("TRACK", "Track1")
.Send(r =>
{
if(r.HasErrors)
Debug.LogError("Error getting GET_RACE_DATA : " + r.Errors.GetString("DETAILS"));
else
{
var gsData = new GSData(r.ScriptData);
object[] list = gsData.GetObjectList("fastestRaceData").ToArray();
foreach (var l in list)
{
var dic = (Dictionary<string, object>)l;
foreach(var key in dic.Keys)
Debug.Log("key = " + key.ToString());
}
}
});
D
Daniel Heinenberg
said
almost 7 years ago
This sounds exactly like what I am looking for (query something from the pool of NoSQL-Datasets).
Could you help me on how to Setup the GameSpark-Side for the above code? Cloud Code, Events?
Thanks,
Daniel
G
Greg Quinn
said
almost 7 years ago
Daniel check out Youtube and the GameSparks docs for tutorials on how to set those things up.
Greg Quinn
I have created a custom table in my NoSql database explorer.
This table contains general game and configuration data that I want to download to the client.
I am looking through the API and forums but cannot find how this data is queried.
I am using the Unity 5 SDK.
Thanks
Thanks for all the help, I found the following code on the forums that uses LogEventRequest to query any event from the Unity3D client...
- Oldest First
- Popular
- Newest First
Sorted by Oldest FirstAyyappa R
I suppose you are asking for collections.
Custom Game Collections
Meta Collection Ref
Have a look at SparkCursor. It could be a good place to start.
Greg Quinn
How do I access that from the Unity client API? I only see SparkCursor as CloudCode.
Ayyappa R
Yes Spark API is cloud API.
I see only possibility passing via Cloud code trough events. I mean fetch the results in cloud code and send as result for an event api call.
Greg Quinn
Do you have an example of how to call these cloud code events from the client?
I've looked everywhere but nothing in the docs explains how to do this.
Thanks
Ayyappa R
Hi,
To be frank I didn't try on this much as remove call on collection was not working earlier. You can refer to previous post on the problem started by Luis i guess. Sadly till now there was no response from GS team on that.
However,
I had a quick test as not having enough time currently, sorry if its not much clear enough, but i'm sure it might help you for sure.
Let me know if I can help you out.
Btw, the above is a cloud code i attached to an event. Just create an event with the required details and get the data by Spark.getData().ATTRIBUTE_NAME and you can save the details in the corresponding cloud script similar to above what I did.
Thanks,
VoxelBusters.com
@voxelbusters
Greg Quinn
Thanks for all the help, I found the following code on the forums that uses LogEventRequest to query any event from the Unity3D client...
Daniel Heinenberg
This sounds exactly like what I am looking for (query something from the pool of NoSQL-Datasets).
Could you help me on how to Setup the GameSpark-Side for the above code? Cloud Code, Events?
Thanks,
Daniel
Greg Quinn
Daniel check out Youtube and the GameSparks docs for tutorials on how to set those things up.
-
Documentation Notes
-
Design issues with user events
-
Using NoSQL
-
Runtime Collections vs Metadata Collections
-
Anonymous authentication from browser app
-
Modules
-
Movement With Unity
-
Problem with url parameters for downloadables
-
Querying NoSql GameSparks database
-
Challenge accesType
See all 2487 topics