There are various types of NoSQL databases. Some categories are given below with popular database example
• Column store: Accumulo, Cassandra, HBase1 2 3 4 5 6 | xquery version "3.0" encoding "UTF-8"; let $msg := 'Hello XQuery' return <results timestamp="{current-dateTime()}"> <message>{$msg}</message> </results> |
1 2 3 | for $x in doc("books.xml")/bookstore/book where $x/price>30 return $x/title |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | function _:add-post( $name as xs:string, $opts as xs:string*, $path as xs:string, $file as map(*), $binary as xs:string? ) { cons:check(), try { let $key := map:keys($file) let $path := if(not($path) or ends-with($path, '/')) then ($path || $key) else $path let $content := $file($key) return if(not($key)) then ( error((), "No input specified.") ) else if(util:eval('db:exists($n, $p)', map { 'n': $name, 'p': $path })) then ( error((), 'Resource already exists: ' || $path || '.') ) else ( if($binary) then ( util:update('db:store($n, $p, $c)', map { 'n': $name, 'p': $path, 'c': $content }) ) else ( let $xml := try { convert:binary-to-string($content) } catch * { error($err:code, replace($err:description, '^.*\): ', '')) } return util:update('db:add($n, $x, $p)', map { 'n': $name, 'x': $xml, 'p': $path }) ), db:output(web:redirect($_:SUB, map { 'name': $name, 'path': $path, 'info': 'Added resource: ' || $name })) ) } catch * { db:output(web:redirect("add", map { 'error': $err:description, 'name': $name, 'opts': $opts, 'path': $path, 'binary': $binary })) } }; |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | function _:addlabel( $name as xs:string, $label as xs:string, $labelvalue as xs:string, $nodename as xs:string ) { cons:check(), try { let $key := $label return if(not($key)) then ( error((), "No search input.")) else( util:update("let $node:= concat('<',$label ,'>', $labelvalue,'</',$label ,'>') let $newnode:=fn:parse-xml($node) for $q in collection($n)//descendant::* where xs:string(fn:node-name($q)) = $nodename return insert node $newnode as last into $q", map { 'n': $name,'label': $label,'labelvalue': $labelvalue,'nodename': $nodename} )), db:output(web:redirect($_:SUB, map { 'info': 'New node was added.', 'name': $name, 'label': $label })) } catch * { db:output(web:redirect("addlabel", map { 'error': $err:description, 'name': $name, 'label': $label })) } }; |