No SQL queries
- Retrieve the whole document using the document key (unique identifier of a document), by invoking Query API
- Define sophisticated queries to search for document matching your criteria, using the Query API as well
Back to the map Next station: Apply validation
Example 1: load my saved game
So you are implementing a cool game that runs on mobile devices, such as smartphones or tablets. Since game data has to be accessible from any device owned by the user, you decided to persist it as an Apstrata document. What you need now is to load the game data back to the device, i.e. get the corresponding document using its document key (we assume our document has the following key 1EB1FFB956C9D0D7155C7422749F485A).
Try it!Example 2: get top 10 highest scores, in descending order
Imagine you need to add a "hall of fame" section in your application, where the player can see the 10 best scores, the corresponding level and the name of the player. All you have to do is to create a query which returns no more than 10 results and such as "score > 0". You also should specify the sort order (descending). Let us see how easy this is to implement with the Apstrata Query API:
Try it!Example 3: get highest scores grouped by level
Now let us say that you would like to know what are the highest scores per game level. What you need is to group the results of your query by the "level" field. This is easily done using the "apsdb.aggregateGroupBy" parameter of the Query API.
Try it!