Message:

Data Service (50 posts)

All available APIs for creating, updating and deleting objects in the Backendless database operate on single objects. It means when you need to store multiple objects in the database, each object requires a separate API call. This increases the number of API calls your app makes. While it is great for us (hey, our billing is based on the API calls), it is not that great for your app as it results in longer processing times and substandard user experience. Starting today, with the release of Backendless version 4.5.0 we’re introducing the new APIs which will allow you to create, update or delete multiple objects with a single API call.

Bulk Create

Saving multiple new objects in the database is now as simple as passing an array of objects to the server. The server responds with a collection of objectId values (which, for example, can be used in the createRelation  API). The bulk create API is supported in all SDKs as well as the REST interface.

Bulk Update

To update objects in the database, the API accepts a condition (where clause) which identifies a group of objects. In addition to the condition, the client must also provide an object containing the changes which should be applies to the selected objects.

Bulk Delete

Similar to “Bulk Update”, this API receives a condition which identifies a group of objects to be deleted.

All of the APIs can be extended using custom business logic’s before/after events.

You can find the documentation for these APIs in the developer guides:

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:

We conducted a webinar titled “Backendless Core Concepts” for ex-Parses last week. A recording of the webinar is now available. The video should be helpful not only if you’re coming from Parse, but for anyone who is starting their journey with Backendless. The webinar reviewed the concepts of Backendless User and Data services. Specifically, we focused on:

  • user properties
  • setting up user relations
  • registering a user
  • registering a user with custom properties
  • configuring a data model
  • code-driven schema creation
  • data relations
  • a brief overview of Cloud Code

In my previous post I described how data tables in Backendless map to the client-side classes whose instances contain persisted data objects. However, there are scenarios when the default mapping is undesirable. In that case, Backendless client libraries provide an API to override the mapping. For example, consider the following data table (Restaurant):
restaurant table schema1 - Feature 123: Custom mapping between Data tables and Client classes

Continue reading

It may already be obvious if you had followed this blog series. Data tables created in Backendless and the client-side classes you write or obtain through Backendless code generation, have a direct correlation. By default a table and the corresponding client-side class have the same name. This is true for all Backendless SDKs which support object-oriented data access. This includes Android, Java, Objective-C, Swift, JavaScript, ActionScript and .NET. For example, consider the following data table:
restaurant table schema1 - Feature 122: Client class to data table mapping

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

Backendless REST Console is a tool capable of driving REST queries against Data Service. It is useful when you need to validate a REST command or for testing and diagnostics purposes. REST Console is available in a dedicated tab on the Data screen of the Backendless Console. Previously I wrote how to load data objects using REST Console and how to save a new data object. In this post I will describe the API to delete a data object.

Continue reading

Previously I wrote about the REST Console, which is a part of the Backendless Console. It is a versatile interface which lets you perform a complete CRUD (Create, Retrieve, Update, Delete) set of operations on your data stored in Backendless using the REST interface. One of my previous articles described how to use the REST Console to perform search queries (that’s the Retrieve part of CRUD). In this post I am going to demonstrate how to save new data objects using the REST Console.

Consider the following data table schema:
location table - Feature 117: Creating/saving new data objects using REST Console

Continue reading

In my previous posts I described how a data object may have a related geopoint (or a collection of). One of the benefits of the data-to-geo relationships is search by distance. That means Backendless can search for data objects using the location of the related geopoints. Consider an example from a taxi-reservation system. There may be several cabs-for-hire in the area. Your app needs to locate all available cars within the specified distance from where the customer is located.

The class representing a cab may look like this:

Continue reading

In my previous two posts I described:

Of course both of the operations above can also be accomplished with the API. However, in this post I am going to show how to retrieve a data object which has a related geopoint. Consider the following object:
address object with geo - Feature 101: Loading data objects with related geopoints using API

The Address table has the location column of the GEOPOINT RELATIONSHIP type. There are three data objects in the table and one of them has a related geopoint. The geopoint is shown in the screenshot below.

Notice the geopoint’s metadata ( city: NEW YORK CITY ):

Continue reading
Find us in facebook