crelte / queries / vars
Variable: vars
const vars: object;Type Declaration
any()
any: () => QueryVar<any>;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>;Returns
QueryVar<number>
siteId()
siteId: () => QueryVar<number>;Returns
QueryVar<number>
string()
string: () => QueryVar<string>;Returns
QueryVar<string>