db:open() - other ways to set context or declare the db?
Hi, Using restxq, do all queries have to begin with db:open('web_app_db')//myquery/here , or can the database be declared? Or set as default somewhere? Thanks, Colin
On 05.11.2012, at 17:40, Colin McEnearney wrote:
Hi,
Using restxq, do all queries have to begin with db:open('web_app_db')//myquery/here , or can the database be declared? Or set as default somewhere?
Thanks, Colin
Hi Colin, we use db:open all over the place. (: ----------------------------------------------------- :) module namespace _ = 'com.gmail.colinmcenearney.db'; declare namespace restxq = "http://exquery.org/ns/restxq"; (: Database name used throughout the application. :) declare variable $_:MY-DB := '_catalog'; (:~ Show users page. :) declare %restxq:path("/show-users") %output:method("html") function _:show-users() { <div> { serialize(db:open($_:MY-DB)//user/@id) } </div> }; (: ----------------------------------------------------- :) Database name declarations often go to a constants.xqm. Cheers, Alex
Thanks Alex! Good to know you use that construct a lot, and that it's not a bad practice for any reason On Mon, Nov 5, 2012 at 5:07 PM, Alexander Holupirek < alexander.holupirek@uni-konstanz.de> wrote:
On 05.11.2012, at 17:40, Colin McEnearney wrote:
Hi,
Using restxq, do all queries have to begin with db:open('web_app_db')//myquery/here , or can the database be declared? Or set as default somewhere?
Thanks, Colin
Hi Colin,
we use db:open all over the place.
(: ----------------------------------------------------- :) module namespace _ = 'com.gmail.colinmcenearney.db';
declare namespace restxq = "http://exquery.org/ns/restxq";
(: Database name used throughout the application. :) declare variable $_:MY-DB := '_catalog';
(:~ Show users page. :) declare %restxq:path("/show-users") %output:method("html") function _:show-users() { <div> { serialize(db:open($_:MY-DB)//user/@id) } </div> }; (: ----------------------------------------------------- :)
Database name declarations often go to a constants.xqm.
Cheers, Alex
participants (2)
-
Alexander Holupirek -
Colin McEnearney