TL;DR: For custom types, it’s always better to extend an type’s prototype than to overwrite it.
function Custom() { // constructor
this.constructor.apply(this, arguments); // call the super-type’s constructor
}
Object.assign(
Custom.prototype,
'use strict'; | |
const jsearch = require('/MarkLogic/jsearch'); | |
// Monkey patch | |
const proto = Object.getPrototypeOf( | |
// Doesn’t actually run a query | |
jsearch.collections('.').documents().where(cts.trueQuery()) | |
); | |
const _slice = proto.slice; |
'use strict'; | |
/** | |
* @class | |
*/ | |
class DocumentExistsError extends Error { | |
constructor(uri) { | |
super(); | |
this.uri = uri; | |
this.message = `URI ${String( |
'use strict'; | |
/** Invokes any function as a specific user */ | |
const asUser = (fn, user) => | |
xdmp.invokeFunction(fn, { userId: xdmp.user(user) }); | |
/** The actual function that does the work. */ | |
function _doStuff(param) { | |
return `${param}: ${xdmp.getCurrentUser()}`; | |
} |
/** | |
* | |
* | |
* @param {Set} aaa | |
* @param {Set} bbb | |
* @param {function} [comparator] | |
* @returns {boolean} | |
*/ | |
function equalSets(aaa, bbb, comparator = (x, y) => x === y) { | |
if ('function' !== typeof comparator) { |
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Toggle group</title> | |
<style type="text/css"> | |
.toggleable:before { | |
width: 0.75rem; | |
/* The two arrows have different widths */ | |
display: inline-block; | |
content: '▾'; |
const table = fn.head(xdmp.documentGet(CSV_FILE)).toObject(); // string | |
const rows = table.split('\r\n'); // Parse lines into Array<string> | |
const headers = rows.shift().split(','); // Array<string> | |
// Array of functions used to parse column values | |
// Only need to specify the left-most columns the others will be skipped | |
const types = [ | |
function(columnValue) { | |
return; /* parsed representation or undefined to skip */ | |
} |
#!/usr/bin/env bash | |
# Downloads Query Console workspaces to the current working directory in the | |
# format `{host}_{workspace id}_{timestamp}.workspace`. | |
# | |
# Usage: ./query-console.sh localhost admin '******' | |
# | |
if command -v jq >/dev/null; then | |
: |
TL;DR: For custom types, it’s always better to extend an type’s prototype than to overwrite it.
function Custom() { // constructor
this.constructor.apply(this, arguments); // call the super-type’s constructor
}
Object.assign(
Custom.prototype,
Searches all Query Console workspaces. Uses exact match, like you’d do in the browser’s own find functionality. Only matches current buffers, not histories.
App-Services
databaseqconsole-search.sjs
above into a Query Console query buffer (how meta)findBuffers()
call at bottom to change the actual search termqconsole-internal
) on any of the Query Console data. (Shouldn’t workspaces, queries, and histories be “owned” by a user?)/** | |
* @param {string} path | |
* @param {object} [bindings] | |
* @param {string | Iterable<string>} [collection] | |
* @return {Sequence<Node>} | |
*/ | |
const xpath = (function _memo() { | |
function isIterable(itr, ignoreStrings = false) { | |
if ('string' === typeof itr) return !ignoreStrings; | |
return Boolean(itr && itr[Symbol.iterator]); |