Child pages
  • Create Query components

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

While you can invoke the Query API from your client side and pass it all the required parameters to execute your query, you will most of the time need to reuse this same logic across clients or event across server-side components. Since Apstrata always has modularity and reusability in mind, it allows you to encapsulate your query logic into components, called "Saved Queries" using the SaveQuery API
Back to the map       Next station: Geospatial queries

Example 1: load my saved game

...

Localtab Group
Localtab
titlecURL
Code Block
languagexml
curl "https://varick.apstrata.com/apsdb/rest/O763A7F690/Query?apsws.time=1419263545113
&apsws.authSig=00826da6btdd6514a14986s366d681cf
&apsws.responseType=json
&apsws.authMode=simple
&apsdb.queryName=topScores"
Localtab
titleApstrata script
Code Block
languagejs
// We retrieve the value of the docKey parameter expected by the saved query, from the request
var docKey = request.parameters["docKey"];
var params = {
	"apsdb.queryName": "topScores" // we pass the name of the saved query
}

return apsdb.callApi("Query", params, null);		
Localtab
titleAndroid
Code Block
languagejava
try {
					
	String authKey = "O763A7F690"; // Replace with your Application key
    String baseURL = "https://varick.apstrata.com/apsdb/rest";
                   
    // Sign your call with a signature based on your application key and secret  to authenticate against Apstrata
    // Simple signature is used in this example
    String secret = "S4A0120A6E64952FE75285BD0XD243S2"; // Replace with your application secret
    Connection ownerConnection = new OwnerConnection(baseUrl, authKey, secret);
    Client client = new Client(baseURL, authKey, ownerConnection);
    Client.AuthMode mode = Client.AuthMode.SIMPLE;
                   
    // Prepare the parameters to send to the SaveDocument API                                 
    List<NameValuePair> parameters = new ArrayList<NameValuePair>();               
    parameters.add(new BasicNameValuePair("apsdb.queryName","topScores"));
						
	// Invoke the API using the Client instance and signature mode 
	// note that since we're not passing files, we send "null" in place of the "files" parameter
	response = client.callAPIJson(Query, parameters, null, mode);
} catch (Exception e) {
	response = "Error: " + e.getMessage();
    e.printStackTrace();
} 

Dig deeper

Related tutorials

Navigation Map
NoSQL
NoSQL