Sign In Register

How can we help you today?

Start a new topic

GameDataService: Multiple Conditions and Retrieving all the Data

Hi there,


I'm trying to understand new GDS service. I have 2 questions.


First question is how can we use multiple conditions and sorts. Following code is for single condition which works but what about multiple.

 

//this is for single condition
var query = API.S("createdat").ne(1);
var sort = API.sort("createdat", true);
var resultsOBJ = API.queryItems(dataName, query, sort);

 

The second question is how can i retrieve all the results without any condition. I tried with following code but it didnt work.

var resultsOBJ = API.queryItems(dataName);



Please advise

Thanks





3 people have this question

Here's how I got multiple conditions to work in my code:


var condition = API.N("ID").gt(startIndex - 1);

condition.and(API.N("ID").lt(startIndex + 25));

@Daniele, seems like you're using some code from https://docs.gamesparks.com/tutorials/database-access-and-cloud-storage/searching-for-players-and-teams.html


Perhaps check the value of resultOBJ.error() or make sure the other aspects of your query are working as expected.

queryItems(dataType, null, sort)  does not work.


This is the error:

"@class": ".LogEventResponse",
  "error": {
    "ERROR": "Player might not exist, please check userName again"
  }
}

You can perform an empty query using 'queryItems(dataType, null, sort)'. Bear in mind that a maximum of 100 items will be returned from a query.


Regards,

Vinnie

I also would like to know how to retrieve all items from data service. I don't like this workaround of .ne("any value it may never have")

To answer your question about multiple conditions, the SparkDataCondition has boolean operators. I think the format would look like:

API.S("createdat").ne(1).and( API.S("secondindex").eq("abc") ); ...etc

I also would like to know how to retrieve all items from a dataType.

 

Login to post a comment