GetRandomEntitiesMatching
Gets a list of up to randomCount randomly selected entities from the server based on the where condition and specified maximum return count.
Service | Operation |
---|---|
globalEntity | GET_RANDOM_ENTITIES_MATCHING |
Method Parameters
Parameter | Description |
---|---|
where | Mongo style query string. |
maxReturn | The maximum number of entities to return. |
Usage
http://localhost:3000
- C#
- C++
- Objective-C
- Java
- JavaScript
- Dart
- Cloud Code
- Raw
string where = "{\"entityType\": \"address\"}";
int maxReturn = 10;
SuccessCallback successCallback = (response, cbObject) =>
{
Debug.Log(string.Format("Success | {0}", response));
};
FailureCallback failureCallback = (status, code, error, cbObject) =>
{
Debug.Log(string.Format("Failed | {0} {1} {2}", status, code, error));
};
_bc.GlobalEntityService.GetRandomEntitiesMatching(where, maxReturn, successCallback, failureCallback);
const char *where = "{\"entityType\": \"address\"}";
int maxReturn = 10;
_bc->getGlobalEntityService()->getRandomEntitiesMatching(where, maxReturn, this);
NSString *where = @"{\"entityType\": \"address\"}";
int maxReturn = 10;
BCCompletionBlock successBlock; // define callback
BCErrorCompletionBlock failureBlock; // define callback
[[_bc globalEntityService] getRandomEntitiesMatching:where
maxReturn:maxReturn
completionBlock:successBlock
errorCompletionBlock:failureBlock
cbObject:nil];
String where = "{\"entityType\": \"address\"}";
int maxReturn = 10;
this; // implements IServerCallback
_bc.getGlobalEntityService().getRandomEntitiesMatching(where, maxReturn, this);
public void serverCallback(ServiceName serviceName, ServiceOperation serviceOperation, JSONObject jsonData)
{
System.out.print(String.format("Success | %s", jsonData.toString()));
}
public void serverError(ServiceName serviceName, ServiceOperation serviceOperation, int statusCode, int reasonCode, String jsonError)
{
System.out.print(String.format("Failed | %d %d %s", statusCode, reasonCode, jsonError.toString()));
}
var where = {
"entityType": "address"
};
var maxReturn = 10;
_bc.globalEntity.getRandomEntitiesMatching(where, maxReturn, result =>
{
var status = result.status;
console.log(status + " : " + JSON.stringify(result, null, 2));
});
var where = {
"entityType": "address"
};
var maxReturn = 10;
ServerResponse result = await _bc.globalEntityService.getRandomEntitiesMatching(where:where, maxReturn:maxReturn);
if (result.statusCode == 200) {
print("Success");
} else {
print("Failed ${result.error['status_message'] ?? result.error}");
}
var where = {
"entityType": "address"
};
var maxReturn = 10;
var globalEntityProxy = bridge.getGlobalEntityServiceProxy();
var postResult = globalEntityProxy.getRandomEntitiesMatching(where, maxReturn);
if (postResult.status == 200) {
// Success!
}
{
"service": "globalEntity",
"operation": "GET_RANDOM_ENTITIES_MATCHING",
"data": {
"where": {
"entityType": "address"
},
"maxReturn": 10
}
}
JSON Response
{
"data": {
"entityList": [
{
"gameId": "22459",
"entityId": "007ce17c-7bc0-4c4e-b08a-0f267517778a",
"ownerId": "ef26173d-a736-478c-aa00-5a5cea9962d1",
"entityType": "address",
"entityIndexedId": null,
"version": 1,
"data": {
"street": "1309 Carling"
},
"acl": {
"other": 1
},
"expiresAt": 9223372036854776000,
"timeToLive": null,
"createdAt": 1507580373566,
"updatedAt": 1507580373566
},
{
"gameId": "22459",
"entityId": "9bc36964-08e5-453c-ac71-142a3b66ca22",
"ownerId": "ef26173d-a736-478c-aa00-5a5cea9962d1",
"entityType": "address",
"entityIndexedId": null,
"version": 1,
"data": {
"street": "1309 Carling"
},
"acl": {
"other": 1
},
"expiresAt": 9223372036854776000,
"timeToLive": null,
"createdAt": 1507580372711,
"updatedAt": 1507580372711
}
],
"_serverTime": 1637946319239,
"entityListCount": 2
},
"status": 200
}