Hello,

I'm creating forms using XForms and BaseX.
For some of them, I need to use a lot of data, so I've set up a search form that loads an XForms instance at every change in the field, from an internal link like this:

/xml/persons/search?query=[search field content].


BaseX responds with RESTXQ:

declare
    %rest:path('/xml/persons/search')
    %rest:produces('application/xml')
    %rest:query-param('query', '{$query}')
    function searchPersons($query){
        <persons>
            db:get(myBase)//*:persons[ . contains text {fn:lower-case($query)} using fuzzy]
        </persons>
};

Although I only enable searches with 3 characters or more, each change to the search field creates a new call to db:get(), which, if I understand correctly, is not recommended.
Could using a variable in the RESTXQ file solve this problem ? Something like :  

declare variable $project:allPersons := db:get(myBase)//*:persons 

and then only using this new var ?

If not, how can I avoid to call to much db:get()?

Thank you very much for your answers.

Regards,

Laurent