Custom Queries
Custom Queries
One of the tools that the AnythingDB module makes available to users is called Custom Queries. Tthis function offers the ability to perform queries directly on the AnythingDB database where the information of the different data models (Things and Categories) defined by the users is stored.
In this way, you will be able to perform complex queries on the data stored in the platform and similarly develop and test complex queries that can later be incorporated into the business logic implemented in the Workers of the Function module.

Figure 1.
Thing Diagram

Figure 2.
Running AnythingDB Queries

Figure 3.
- query
- The Anything DB query itself with the data to be collected from the database.
- count
- True/False, define a count of items matching the query that should be returned in the result or not.
- batchSize
- Defines the number of elements to display in the response
- bindVars
- Variables referenced in the query
- code
- Response status code
- count
- Number of elements that matched the query
- error
- True / false, depending on existing errors
- extra
- (stats): Stats about the execution of the query
- id
- See the pagination section below for more information
- hasMore
- True / false depending on if all elements were returned in result
- result
- Elements returned by the query.
Example Queries

Figure 5.
To use these examples, replace the values in the bindVars parameter of the body.
Using AnythingDB Queries from a Worker
A powerful way to explore the use of AnythingDB from within the SmartWorks platform is by automating these queries through the use of functions. To be able to incorporate calls in the functions, use the https protocol using a POST call.
https://api.swx.altairone.com/beta/spaces/develop/query/cursor/
The body of the POST call must include in JSON format the fields defined above, where the query to be made will be included.
Pagination
Occasionally, the result returned after a query will not show all the results. This will be indicated in the response field with the title hasMore. To access the rest of the results, use the field "id" that is returned in the query result.
https://api.swx.altairone.com/beta/spaces/develop/query/cursor/id
You can make calls to this url sequentially until you get the rest of the values. The hasMore field will return false when the last data has been displayed.
Documentation
To learn more about AnythingDB Beta, you can access its documentation by clicking
.