Message:

REST (4 posts)

Performing a calculation on a group of database objects may be a complex task. For example, to calculate the sum of all orders for a customer would require retrieving all customer’s orders, iterating over them to calculate the mathematical sum of all amounts. This was yesterday! As of Backendless 4.4.0, you can use aggregate functions to calculate the average, sum, maximum and minimum values for a collection of objects without retrieving them from the server. Additionally, the system supports calculating object count for all records in the database or a record subset.

To use an aggregate function, simply request a property in a data retrieval request in the following format (the example below is for calculating the sum for the orderAmount  column):

The returned object includes the sum  property with the calculated value:

The name of the property can be modified by assigning an alias (using %20  to replace the spaces in the URL):

The result contains a value for the property named after the alias:

Grouping Results

Results can be grouped by a column. The column could be either in the same table or a related one. For example, the following request retrieves the sum of all orders grouped by related country:

Unlike the response above, the result for this query includes a collection of objects, each containing the sum for a related country:

It is also possible to apply a filter on the grouped values. This can be done using the having  clause. For example, the request below retrieves only the groups of countries where the total order amount is greater than 10000:

For more information about aggregate functions see the Backendless API documentation:

Quite often you need to run a test query or send an API request to see the server response. Our REST docs show examples using curl , but at times it may be inconvenient. You may need to play with the API request arguments, change the body, etc and modifying your curl  command is not as straightforward. To make it easier, we create a collection of our APIs for Postman. If you are not familiar with Postman, it is a desktop tool that lets you run API requests, see the server responses, you can easily change the endpoint URLs, request headers and body. Adding our APIs collection into Postman is now as simple as a click of a button because that button is integrated directly into Backendless Console. Check out the video below for an overview of the integration.

Posted in REST

It feels really amazing to begin writing this blog post. We got caught in an unusually long release cycle, spent months iterating over the new features, improvements and bug fixes, but in the end it was well worth it. We did it! Backendless 2.0 is here and the product is as cool and powerful as ever. With this release we made several very firm steps towards establishing the Backendless Platform – a unified system for designing, developing, running and managing backend services.

The release brings four major new features and about a dozen at а smaller scale. All of the new features are distinct differentiators of our product making it the strongest mobile backend as a service offering on the market. So without any further ado, let me introduce the new additions to our feature line up:

Continue reading

Previously I described how to save data objects using REST Console. The same interface allows to save objects with related data – it is strictly a matter of formatting the request body. Consider the following two data table schemas:

Restaurant table schema:
restaurant table schema1 - Feature 121: Adding objects with relations using REST Console

Continue reading