Created
May 14, 2014 14:47
-
-
Save ableasdale/aa3da34ba8f5e5d96f08 to your computer and use it in GitHub Desktop.
Create sample data in a given database quickly
This file contains hidden or 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"; | |
declare private function local:random-hex($length as xs:integer) as xs:string { | |
fn:string-join(for $n in 1 to $length | |
return xdmp:integer-to-hex(xdmp:random(15)), | |
"" | |
) | |
}; | |
declare function local:generate-uuid-v4() as xs:string { | |
fn:string-join( | |
( | |
local:random-hex(8), | |
local:random-hex(4), | |
local:random-hex(4), | |
local:random-hex(4), | |
local:random-hex(12) | |
), | |
"-" | |
) | |
}; | |
(: main :) | |
for $i in (1 to 50000) | |
let $guid := local:generate-uuid-v4() | |
return | |
xdmp:document-insert(concat($guid,".xml"), | |
<data> | |
<dateTime>{fn:current-dateTime()}</dateTime> | |
<guid>{$guid}</guid> | |
</data>) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment