Skip to content

Instantly share code, notes, and snippets.

View dmcassel's full-sized avatar

David Cassel dmcassel

View GitHub Profile
"hop": {
"type": "Perle (DE)",
"uri": "/hop/perle-de.json",
"use": "boil",
"time": {
"units": "min",
"amount": 60
"aau": 4.5
cts:search(fn:doc(), cts:and-query((
dmcassel / Contributor.json
Last active October 14, 2015 00:47
MarkLogic 8 for Node.js Developers
"com.marklogic.samplestack.domain.Contributor": {
"aboutMe": "Twitter: [@maryadmin]( Disclaimer: This is not me. MaryAdmin _doesn't exist_!",
"displayName": "MaryAdmin",
"id": "9611450a-0663-45a5-8a08-f1c71320475e",
"location": "Barrow",
"originalId": null,
"reputation": 100,
"userName": "",
"voteCount": 5,
dmcassel /
Last active September 23, 2015 20:16
REST API Setup steps
curl -v -X PUT --anyauth -u admin:admin \
--header "Content-Type:application/json" \
-d '{"collection-lexicon":true}' \
dmcassel /
Last active September 23, 2015 13:29 — forked from evanlenz/
Code samples for MarkLogic REST API
curl -X GET \
--anyauth --user rest-writer:x \
switch(xdmp.getRequestMethod()) {
case "GET":
// Get the criterion out of the URL query string
var q = cts.wordQuery(xdmp.getRequestField("q"));
// Unwind the iterator into an Array
var results =;
xdmp.addResponseHeader("X-Result-Count", results.length + "");
// Serialize the JavaScript results object as JSON
: Evaluate JavaScript from XQuery, passing in external variables and returning
: results as XQuery types.
"var result = []; for(var p in param) {result.push(p); result.push(param[p]);} result;",
(xs:QName("param"), object-node { "a": "A", "b": "B"})
* Access the values from a range index.
* (Note: This assumes you've created the path range index on the
* balance.value field in "Import XQuery")
// Any reference to a range index
* Demonstrate an object-oriented style of programming. Declare a Person type
* and instantiate an instance. Convert that instance into a JSON node, for
* example to persist it to the database, and convert it back.
// The Person constructor, e.g. var p = new Person(…)
Person = function(fname, lname) {
if (fname) this.fname = fname;
if (lname) this.lname = lname;
"guid": "986af6e1-e0f1-450f-b1f0-2eff54357840",
"about": [
"Skateboard pop-up kogi, ethnic Vice disrupt Truffaut twee fashion axe forage occupy biodiesel. Bespoke umami yr, ",
"match": "flannel"
" kogi XOXO bitters butcher ugh DIY lomo. Flexitarian distillery ",