crelte / queries / vars
Variable: vars
const vars: object;Type Declaration
any
any: () => QueryVar<any>;Any is not validated except for nullability
Returns
QueryVar<any>
id
id: () => QueryVar<number>;Id is almost the same as number but will also parse strings, but only allow non negative integers
Warning
Ids are not automatically safe to be cached you need to validate the response to make sure filters with this id returned something
Returns
QueryVar<number>
ids
ids: () => QueryVar<number[]>;Ids is an array of ids it will also convert a single id to an array with one element the returned array will never be empty, but might be null if allowed. Id's are always non negative integers
The numbers are always unique and sorted in ascending order
Warning
Ids are not automatically safe to be cached, it is also not enough to just check if the filter returned some results. Since for example a relatedTo filter works like an or and not an and meaning if you request ids [1,2,3] and only 1 and 3 have related entries you will get results even though id 2 did not return anything.
To mitigate this you could do a second query with the filtered ids in the field, and check if the return matches the length.
Returns
QueryVar<number[]>
number
number: () => QueryVar<number>;Number is a number, but will also parse strings to numbers
Returns
QueryVar<number>
siteId
siteId: () => QueryVar<number>;Checks for a valid site id which exists
Returns
QueryVar<number>
string
string: () => QueryVar<string>;String is a string, but will not parse numbers to strings
Returns
QueryVar<string>
strings
strings: () => QueryVar<string[]>;Strings is an array of strings, but will also convert a single string to an array with one element
Note
The returned array will never be empty, but might be null if allowed. It is not deduped or sorted. If you have ids you should use vars.ids() instead.
Returns
QueryVar<string[]>