Skip to content

Instantly share code, notes, and snippets.

@ableasdale
Created August 12, 2015 14:36
Show Gist options
  • Save ableasdale/4f58ca872871c25f78f2 to your computer and use it in GitHub Desktop.
Save ableasdale/4f58ca872871c25f78f2 to your computer and use it in GitHub Desktop.
Create ML / SQL Views
xquery version "1.0-ml";
import module namespace view = "http://marklogic.com/xdmp/view"
at "/MarkLogic/views.xqy";
declare option xdmp:mapping 'false';
let $_schema_remove :=
let $current := try { view:schema-get ('main') } catch ($e) { () }
return
if (fn:exists ($current)) then view:schema-remove ('main') else ()
let $_schema_add := view:schema-create("main", ())
let $_views_add :=
for $view in /views/view:view
return
view:create(
"main",
$view/view:view-name/fn:string(),
$view/(view:element-scope|view:collection-scope),
($view/view:columns/view:column),
(),
() )
return ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment