Sign In Register

How can we help you today?

Start a new topic

Data Explorer query returns nothing

I created a data type PLAYER with CITY field, after that I added two players with Insert tab in Data Explorer. I can find both players by Id, but any Query returns nothing. I thied with no rules, rules with some CITY fields (they definilety exists). That i am doing wrong?


Hi Vladimir,


If you've got the city field created then it is indexed and will be queryable. What query are you using here exactly ?


Regards,

Liam

Hi,


Thanks for the quick response!


I attached two screenshots with query example in Data Explorer.

I also tried get query with followed cloud code:


var API = Spark.getGameDataService();


// Tried two variants

1) var condition = API.S("CITY").eq("New York")

2) var condition = API.S("CITY").ne("some random string")


var query = API.queryItems("PLAYER", condition);


if(query.error()){

    //Output error script

    Spark.setScriptError("ERROR", query.error());

    //Stop execution of script

    Spark.exit();    

} else{

    //Create empty object

    var entryOBJ = {};

    //While there are still entries in the cursor retrieved from query

    while(query.cursor().hasNext()){

        //Get the entry

        entry = query.cursor().next();

        //Populate object with the entries. key = entry ID

        entryOBJ[entry.getId()] = entry.getData();


    }

    //Return entries via scriptData

    Spark.setScriptData("data", entryOBJ);

}



My data field in response always empty.



Query.png
(74.5 KB)
Find.png
(126 KB)

Hi Vladimir,


I think the data type path is not configured correctly here. Can you change the path for "CITY" to "CITY" and try the query again please ?


Regards,

Liam

Yea, it works! Thank you very much.


I used this Adding a Game Data Index tutorial and therein Short Code and Path are different. This confused me. Perhaps a remark is needed that they should be the same.


Regards,

Vladimir

Login to post a comment