Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added an easy key/value endpoint to access single documents. This cou…

…ld be especially useful to grab documents by id's.
  • Loading branch information...
commit 84d58ad3e504b8335aa970c028897819343d8cab 1 parent 8a471ba
@ryangrimm ryangrimm authored
Showing with 25 additions and 0 deletions.
  1. +25 −0 data/kvquery.xqy
View
25 data/kvquery.xqy
@@ -0,0 +1,25 @@
+(:
+Copyright 2011 MarkLogic Corporation
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+:)
+
+xquery version "1.0-ml";
+
+import module namespace json="http://marklogic.com/json" at "lib/json.xqy";
+
+let $query := cts:and-query(
+ for $key in xdmp:get-request-field-names()
+ return cts:element-value-query(xs:QName(json:escapeNCName($key)), xdmp:get-request-field($key))
+)
+return json:xmlToJSON(cts:search(/json, $query)[1])
Please sign in to comment.
Something went wrong with that request. Please try again.