The query syntax is based on the Loopback query filter.
-
All queries must be submitted as a JSON object.
-
When supplying units in a parameter query, the quantity will be converted to SI units for comparison with the value stored in the database. Before returning the results, the relevant quantity is converted to the unit supplied by the user in the query. E.g., if querying a parameter in keV, the quantity will be converted to kg m2 / s2 and compared to the SI value stored in the database. Before returning the results with the relevant quantities to the user, they will be converted to the same unit that the user provided in the query, in this case keV.
The query syntax is written in JSON format:
{
"where": {
"property": "value"
},
"include": [
{
"relation": "relatedModel",
"scope": {
"where": {
"property": "value"
}
}
}
],
"limit": 0,
"skip": 0
}
Documentation on the different filters can be found below.
The where
filter is used to supply match conditions when querying data.
To test equivalence, the filter should be written on the following form:
{"where": {"property": "value"}}
property
- the name of the model property that is being queriedvalue
- the value that the property should be equal to
The filter can also be used to match other conditions than equality, and should then be written on the form of:
{"where": {"property": {"operator": "value"}}}
operator
- one of the operators specified in the Loopback operators documentation (e.g. "lt", "gt", "between") or "text"
The text operator can be used to query data matching a string.
{"where": {"text": "value"}}
The value will then be matched with the following fields (see Example):
Model | Fields |
---|---|
Dataset | Title |
Document | Title, Summary |
File | Name |
Instrument | Name, Facility |
Sample | Name, Description |
Technique | Name |
A query can use logical and
and or
to join queries together. They are written on the following form:
{
"where": {
"and": [
{
"property": "value"
},
{
"property": "value"
}
]
}
}
{
"where": {
"or": [
{
"property": "value"
},
{
"property": "value"
}
]
}
}
Related models may be included by using the include
filter.
To include a related model, the query should be formatted in the following way:
{"include": [{"relation": "relatedModel"}]}
If you want to include additional related models, simply append them to the array, e.g.:
{"include": [{"relation": "relatedModel1"}, {"relation": "relatedModel2"}]}
To include a related model with match conditions, use the scope
property:
{
"include": [
{
"relation": "relatedModel",
"scope": {
"where": {
"property": "value"
}
}
}
]
}
Similarly, to include more than one related model with match conditions:
{
"include": [
{
"relation": "relatedModel1",
"scope": {
"where": {
"property": "value"
}
}
},
{
"relation": "relatedModel2",
"scope": {
"where": {
"property": "value"
}
}
}
]
}
You can limit the number of queries by adding
{"limit": 0}
to the filter. It is not necessary to include this filter if the value is 0.
Results can be skipped using the skip
property
{"skip": 0}
It is not necessary to include this filter if the value is 0.