getmethod of the
Simbla.Queryto perform actions on a certain single object. After reading the next guide, you will be able to use
Simbla.Queryto perform different actions on many objects at once and not just on one single object.
findIn order to retrieve an
Simbla.objects. In our next example we are going to use the
equalTomethod to call back all the white cars.
simbla.query can retrieve multiple objects. To filter the results you can endow several constraints.
notEquelTo to filter out objects with a similar value :
Adding multiple constraints is possible; they will act like they are connected with AND in between them, but only objects that match all constraints will be retrieved.
By default, the results are limited to 100, but if you wish to change it you can set a
limit from 1 to 1000. By default, the results will be sorted by the first entered, meaning if you have 100 results and you limit them to 30, the first 30 will be presented and not the last 30.
If you wish to show the last 30 out of the 100, simply
skip the first 70:
If you wish to retrieve only one result, use the
In order to sort the order of the retrieved objects(strings and numbers) use the following:
Comparisons can be used only on sortable objects(strings and numbers):
Instead of using multiple queries in order to retrieve an object out of a list of values, you can use the
containedIn that provides an array of values.
For example, if you wish to find a car only from a specific list of car colors:
You can use the
notContainedIn to retrieve object that appear out of the list:
exists to retrieve objects that have a particular key set, or use
doesNotExist to retrieve objects that do not have a particular key set.
You can call back only certain fields. For this example, we can only retrieve "car code" and "car model" fields by using
startsWith to retrieve string values that start with (" ").
For our example we will retrieve any car whose model starts with "Porsche;", in return we will get our "Porsche cayman" and "Porsche 911" but not any other values like: "porsche cayman" or "cayman Porsche".
If you wish to count how many objects match without retrieving them, use the
count method. Below you will find a counter counting how many times "ford Shelby" appears in our table.
If you want to find an object that matches several queries, you can use the
Simbla.Query.or method. In our next example we are going to present the results of both old cars(under 2014) and new cars(above 2015) :