queryparameter
Query Filter
Query filter documents specify the conditions that determine which records to select for read, update, and delete operations.
You can use : expressions to specify the equality condition and query operator expressions.
{
<field1>: <value1>,
<field2>: { <operator>: <value> },
...
}
$type Operator
All query parameters that start with “$” symbol include $go, $max, $sort, $fit, and $sip. Query parameter is below the Get function of X method, therefore query parameters must be used in the Get function. To manipulate, for instance:
tim.X("test").Get($go:90);
$go
Jump to the record of the input number.
tim.X("test").Get({$go:90});
$max ( $max )
The size parameter specifies the size of the return collection in number.
By default, queries in X-Server return all fields in matching documents. To limit the amount of data that X-Server sends to applications, you can include a projection document to specify or restrict fields to return.
For example, set the amount of return data to 10:
tim.X("test").Get({$max:10});
$sort
sort data.
To retrieve documents in reverse insertion order, issue Get() along with the $sort method with the $natural parameter set to -1, and set to 1 is ascending, as shown in the following example:
tim.X("test").Get({
$sort: {
_t: -1
}
})
$fit
Instead of listing the fields to return in the matching document, you can use a $fit array to exclude specific fields. The following example which only return and include some fields in this array parameter.
tim.X("test").Get({$fit:["name","age"]});
If you do not specify a $fit array, the Get() method returns all fields in the matching documents.
$sip
Sip is the process of automatically replacing the specified paths in the document with document(s) from other collection(s). We may reference a single document, multiple documents, plain object, multiple plain objects, or all objects returned from a query in other collections. Let's look at an example.
tim.X("test").Get({$sip:"test2"});
Pagination function
The pagination options can be set as follows:
tim.X("test").Get($max:pageSize,$go:pageSize*pageNumber);
For example, page size is 10 and go to the third page, set $go=$max x 3 = 30
tim.X("test").Get($max:10,$go:30);
Go to the tenth page: set $go=$max x 10 = 100
tim.X("test").Get($max:10,$go:100);
Query Efficiency
Use natural ordering to retrieve the most recently inserted elements from the collection efficiently.
Last updated