Created
August 12, 2015 14:36
-
-
Save ableasdale/4f58ca872871c25f78f2 to your computer and use it in GitHub Desktop.
Create ML / SQL Views
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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