Class: mljs

mljs

new mljs()

Creates an mljs instance. Aliased to new mljs().

Source:
Tutorials:

Classes

documentcontext
geocontext
options
query
searchcontext
semanticcontext
sparqlbuilder

Members

textToXML

Node JS mljs namespace function mappings

Source:

Methods

alertcontext()

Supports the MLJS WebServer W3C WebSockets based alert channel capability. Requires Node.js running the MLJS web server. This provides for real time alerting from the database directly to (multiple) browser clients. This alert context is very low level, leaving higher level message unpacking to application specific plugins.

Source:

beginTransaction(name_opt, callback)

Opens a new transaction. Optionally, specify your own name.

http://docs.marklogic.com/REST/POST/v1/transactions

Note: Each mljs instance can only have one live transaction at a time. This is a limit imposed by myself by design, not by the underlying REST API. Best to configure a connection per real user-application pair.

Parameters:
Name Type Description
name_opt string

The name of the transaction. If not provided, 'client-txn' will be used. Likely not safe on a multi user system.

callback function

The callback to invoke after the method completes

Source:

collect(collection, fields_opt, callback_opt)

Returns all documents in a collection, optionally matching against the specified fields

http://docs.marklogic.com/REST/GET/v1/search

Parameters:
Name Type Description
collection string

The collection to list documents from

fields_opt string

Not used

callback_opt function

The optional callback to invoke after the method completes

Source:

collections(parenturi_opt, callback)

Lists the collection URIS underneath the parent uri. Helper method to fetch collections from the collection lexicon using mljs.valuesCombined().

Parameters:
Name Type Description
parenturi_opt string

The collection URI under which to retrieve the list of subcollections. Defaults to "/"

callback function

The callback to invoke after the method completes

Source:

combined(structuredQuery_opt, textQuery_opt, optionsdoc, sprops_opt, callback)

Performs a MarkLogic Server V7+ Combined query. This submits options along with the query term. It can also include both structured and plain text query terms in one call.

http://docs.marklogic.com/REST/GET/v1/search

Uses structured search instead of cts:query style searches. See http://docs.marklogic.com/guide/search-dev/search-api#id_53458

Use this method in conjunction with the Query Builder {@see mljs.prototype.query}

Parameters:
Name Type Description
structuredQuery_opt JSON

The optional structured query JSON to restrict the results by

textQuery_opt string

The query string. Optional. (Returns all documents if not supplied, or whatever returns from the additional-query in the json options used)

optionsdoc string

The optional query options object to use (NOT the name of query options already saved)

sprops_opt JSON

Additional optional search properties

callback function

The callback to invoke after the method completes

Source:

commitTransaction(callback)

Parameters:
Name Type Description
callback function

The callback to invoke after the method completes

Source:

configure(dboptions)

Provide configuration information to this database. This is merged with the defaults.

Parameters:
Name Type Description
dboptions mljs.dboptions

The DB Options to merge with the default options for this connection.

Source:

create(options_opt, callback_opt)

Creates the database and rest server if it does not already exist

Parameters:
Name Type Description
options_opt mljs.dboptions

Optional separate database options. Defaults to normal connection options. Useful to override if creating an app server for writing content to the modules database.

callback_opt function

The optional callback to invoke after the method completes

Source:

createAlertContext()

Factory pattern. Creates an alert context object referring back to the current database connection. Useful to link to the correct logger, and db settings.

Deprecated:
  • Instantiate externally (See Workplace Context) then call linkContext(contextInstance).
    Source:

    createDataContext()

    Factory pattern. Creates a data context object referring back to the current database connection. Useful to link to the correct logger, and db settings.

    Deprecated:
    • Instantiate externally (See Workplace Context) then call linkContext(contextInstance).
      Source:

      createDocumentContext()

      Factory pattern. Creates a content search context object referring back to the current database connection. Useful to link to the correct logger, and db settings.

      Deprecated:
      • Instantiate externally (See Workplace Context) then call linkContext(contextInstance).
        Source:

        createGeoContext()

        Factory pattern. Creates a geo (locale) context object referring back to the current database connection. Useful to link to the correct logger, and db settings.

        Deprecated:
        • Instantiate externally (See Workplace Context) then call linkContext(contextInstance).
          Source:

          createOptions()

          Factory pattern. Creates an options object referring back to the current database connection. Useful to link to the correct logger, and db settings.

          Source:

          createQuery()

          Factory pattern. Creates an options object referring back to the current database connection. Useful to link to the correct logger, and db settings.

          Source:

          createSearchContext()

          Factory pattern. Creates a content search context object referring back to the current database connection. Useful to link to the correct logger, and db settings.

          Deprecated:
          • Instantiate externally (See Workplace Context) then call linkContext(contextInstance).
            Source:

            createSemanticContext()

            Factory pattern. Creates a semantic context object referring back to the current database connection. Useful to link to the correct logger, and db settings.

            Deprecated:
            • Instantiate externally (See Workplace Context) then call linkContext(contextInstance).
              Source:

              createSessionContext()

              Factory pattern. Creates a session context object referring back to the current database connection. Useful to link to the correct logger, and db settings.

              Deprecated:
              • Instantiate externally (See Workplace Context) then call linkContext(contextInstance).
                Source:

                createTripleConfig()

                Factory pattern. Creates a semantic config object referring back to the current database connection. Useful to link to the correct logger, and db settings.

                Deprecated:
                • Instantiate externally (See Workplace Context) then call linkContext(contextInstance) for semantic context, which has an instance of this.
                  Source:

                  databases(callback)

                  Lists all available databases on the server. NOTE: Uses admin port rather than content port

                  Parameters:
                  Name Type Description
                  callback function

                  The callback to invoke after the method completes

                  Source:

                  datacontext()

                  Abstracts data collation from many sources, across multiple calls E.g. one source may be facets from a document query, another triples relating to the subject (reference data), another still may be cooccurence data. This class is an extract of visual functionality in the highcharts and openlayers widgets.

                  Source:

                  delete(docuri, callback_opt)

                  Parameters:
                  Name Type Description
                  docuri string

                  URI of the document to delete

                  callback_opt function

                  The optional callback to invoke after the method completes

                  Source:

                  deleteAll(callback)

                  Deletes ALL documents and triples in the content database

                  Uses deleteUsingSearch()

                  Parameters:
                  Name Type Description
                  callback function

                  The optional callback to invoke after the method completes

                  Source:

                  deleteGraph(uri, callback_opt)

                  Deletes the specified graph from MarkLogic Server

                  http://docs.marklogic.com/REST/DELETE/v1/graphs

                  Parameters:
                  Name Type Description
                  uri string

                  The name of the graph to delete. Required. (Cannot be 'default')

                  callback_opt function

                  The optional callback to invoke after the method completes

                  Source:

                  deleteSavedSearch(searchname, callback_opt)

                  REQUIRES CUSTOM REST API EXTENSION - subscribe-resource.xqy - Adam Fowler adam.fowler@marklogic.com - Save searches by name, and subscribe to alerts from them. Alerts sent to a given URL.

                  Delete the saved search. Assumes already unsubscribed from alerts used by it. (If not, alerts will still fire!)

                  Parameters:
                  Name Type Description
                  searchname string

                  The name of the search

                  callback_opt function

                  The optional callback to invoke after the method completes

                  Source:

                  deleteTransform(name, callback_opt)

                  Parameters:
                  Name Type Description
                  name string

                  The internal name of the transform to delete

                  callback_opt function

                  The optional callback function

                  Source:

                  deleteUsingSearch(query_opt, options_opt, sprops_opt, callback)

                  Deletes ALL content matching a search

                  http://docs.marklogic.com/REST/DELETE/v1/search

                  See supported search grammar http://docs.marklogic.com/guide/search-dev/search-api#id_41745

                  Supported values for sprops_opt:-

                  • collection - The collection to restrict search results from
                  • directory - The directory uri to restrict search results from
                  • transform - The transform to apply to the top level results object on the server
                  • format - The format of the response. json or xml. json is the default if not specified
                  Parameters:
                  Name Type Description
                  query_opt string

                  The query string. Optional. (Returns all documents if not supplied, or whatever returns from the additional-query in the json options used)

                  options_opt string

                  The name of the installed options to use. Optional. In 0.7+ can also be a JSON options document, if used against MarkLogic 7

                  sprops_opt JSON

                  Additional optional search properties

                  callback function

                  The optional callback to invoke after the method completes

                  Source:

                  destroy(callback_opt)

                  Destroys the database and rest api instance

                  Parameters:
                  Name Type Description
                  callback_opt function

                  The optional callback to invoke after the method completes

                  Source:

                  dlscollection(collection, callback)

                  REQUIRES CUSTOM REST API EXTENSION - dls.xqy - Adam Fowler adam.fowler@marklogic.com - Fetching documents within specified DLS collection

                  Parameters:
                  Name Type Description
                  collection string

                  DLS collection to list documents who are members of

                  callback function

                  The callback to invoke after the method completes

                  Source:

                  dlscollections(callback)

                  REQUIRES CUSTOM REST API EXTENSION - dls.xqy - Adam Fowler adam.fowler@marklogic.com - Lists all DLS collections

                  Parameters:
                  Name Type Description
                  callback function

                  The callback to invoke after the method completes

                  Source:

                  dlsdeclare(uri_or_uris, collection, callback)

                  REQUIRES CUSTOM REST API EXTENSION - dls.xqy - Adam Fowler adam.fowler@marklogic.com - Declares documents as members of a DLS collection, and enables DLS management

                  Parameters:
                  Name Type Description
                  uri_or_uris string | Array

                  Documents to declare as records

                  collection string

                  New DLS collection to add documents to

                  callback function

                  The callback to invoke after the method completes

                  Source:

                  dlsrule(name, callback)

                  REQUIRES CUSTOM REST API EXTENSION - dlsrules.xqy - Adam Fowler adam.fowler@marklogic.com - Fetches DLS retention rule

                  Parameters:
                  Name Type Description
                  name string

                  Name of the Rule to fetch configuration of

                  callback function

                  The callback to invoke after the method completes

                  Source:

                  dlsrules(callback)

                  REQUIRES CUSTOM REST API EXTENSION - dlsrules.xqy - Adam Fowler adam.fowler@marklogic.com - Lists all DLS retention rules

                  Parameters:
                  Name Type Description
                  callback function

                  The callback to invoke after the method completes

                  Source:

                  do(options_opt, content_opt, callback_opt)

                  Function allowing mljs's underlying REST invocation mechanism to be used for an arbitrary request.

                  Useful for future proofing should some new functionality come out, or bug discovered that prevents your use of a JavaScript Driver API call.

                  Parameters:
                  Name Type Description
                  options_opt object

                  {method: "GET|POST|PUT|DELETE", path: "/v1/somepath?key=value&format=json"}

                  content_opt object

                  undefined for GET, DELETE, json for PUT, whatever as required for POST

                  callback_opt object

                  the optional callback to invoke after the method has completed

                  Source:

                  exists(callback)

                  Does this database exist? Returns an object, not boolean, to the callback

                  Parameters:
                  Name Type Description
                  callback function

                  The callback function to invoke

                  Source:

                  fast(callback_opt)

                  Generic wrapper to wrap any mljs code you wish to execute in parallel. E.g. uploading a mahoosive CSV file. Wrap ingestcsv with this and watch it fly!

                  NOTE: By default all E-node (app server requests, like the ones issued by this JavaScript wrapper) are executed in a map-reduce style. That is to say they are highly parallelised by the server, automatically, if in a clustered environment. This is NOT what the fast function does. The fast function is intended to wrap utility functionality (like CSV upload) where it may be possible to make throughput gains by running items in parallel. This is akin to ML Content Pump (mlcp)'s -thread_count and -transaction_size ingestion options. See defaultdboptions for details

                  Parameters:
                  Name Type Description
                  callback_opt function

                  The optional callback to invoke after the method completes

                  Source:

                  forceVersion(ver)

                  Forces MLJS to assume the server is a particular version (rather than try to ascertain it itself).

                  Parameters:
                  Name Type Description
                  ver string

                  THe version string. E.g. 6.0-3 or 7.0-1

                  Source:

                  get(docuri, options_opt, callback_opt)

                  Fetches a document with the given URI.

                  https://docs.marklogic.com/REST/GET/v1/documents

                  options_opt currently supports these options:-

                  • transform - the name of the installed transform to use when fetching the document
                  Parameters:
                  Name Type Description
                  docuri string

                  The URI of the document to retrieve

                  options_opt JSON

                  Additional optional options to use

                  callback_opt function

                  The optional callback to invoke after the method completes

                  Source:

                  getTransform(name, callback)

                  Fetches the transform XSLT or XQuery document.

                  http://docs.marklogic.com/REST/GET/v1/config/transforms/[name]

                  Parameters:
                  Name Type Description
                  name string

                  The name of the transform to return

                  callback function

                  The callback function to call. Document will be contained within the JSON result.doc parameter

                  Source:

                  getVersion()

                  Returns the current version string (E.g. 7.0-1) or null if version() has not yet been called.

                  Source:

                  graph(uri_opt, params_opt, callback_opt)

                  Returns the specified graph from MarkLogic Server, or the full default graph. USE CAREFULLY! Returns the triples as a JSON {subject: "...", predicate: "...", object: "..."} array in result.triples, or the raw in result.doc

                  http://docs.marklogic.com/REST/GET/v1/graphs

                  Parameters:
                  Name Type Description
                  uri_opt string

                  The name of the grah to return. If not provided, the default MarkLogic graph (all triples, not just triples not in a named graph) will be returned.

                  params_opt mljs.graphparams

                  JSON containing graph extended properties. E.g. format: "turtle"

                  callback_opt function

                  The optional callback to invoke after the method completes.

                  Source:

                  indexes(callback)

                  Checks whether the database contains indexes for all installed search options.

                  http://docs.marklogic.com/REST/GET/v1/config/indexes

                  Parameters:
                  Name Type Description
                  callback function

                  The callback to invoke after the method completes

                  Source:

                  ingestcsv(csvdata, docid_opt, callback_opt)

                  Takes a csv file and adds to the database. fast aware method

                  NOT YET IMPLEMENTED - Shell function only that will never call the callback

                  Parameters:
                  Name Type Description
                  csvdata string

                  The CSV text to ingest

                  docid_opt string

                  The optional URI of the document to store

                  callback_opt function

                  The optional callback to invoke after the method completes

                  Source:

                  installTrigger(triggerJson, callback)

                  Uses the triggers.xqy REST extension to install a trigger

                  Parameters:
                  Name Type Description
                  triggerJson object

                  The trigger description JSON (as expected by the REST API)

                  callback function

                  The callback function

                  Source:

                  keyvalue(key, value, keytype_opt, callback_opt)

                  Performs a simple key-value search. Of most use to JSON programmers.

                  https://docs.marklogic.com/REST/GET/v1/keyvalue

                  Parameters:
                  Name Type Description
                  key string

                  The JSON key to use for document retrieval

                  value string

                  The value of the JSON key to match against candidate documents

                  keytype_opt string

                  What type to use for the key type. Defaults to 'key'. (i.e. JSON key, not element)

                  callback_opt function

                  The optional callback to invoke after the method completes

                  Source:

                  linkContext()

                  Links context instance to current DB (MLJS) connection instance. Replaces all createContext() functions

                  Source:

                  list(directory, callback_opt)

                  Lists all documents in a directory, to the specified depth (default: 1), optionally matching the specified fields

                  http://docs.marklogic.com/REST/GET/v1/search

                  Parameters:
                  Name Type Description
                  directory string

                  The directory URI to list documents within

                  callback_opt function

                  The optional callback to invoke after the method completes

                  Source:

                  listTransforms(callback)

                  List all transforms available on the REST API instance. Returns their JSON description as per the REST API documentation.

                  http://docs.marklogic.com/REST/GET/v1/config/transforms

                  Parameters:
                  Name Type Description
                  callback function

                  The callback function to invoke. Results in the JSON result.doc parameter

                  Source:

                  merge(json, docuri, callback_opt)

                  Updates the document with the specified uri by only modifying the passed in properties.

                  NB May not be possible in V6 REST API elegantly - may need to do a full fetch, update, save.

                  KNOWN ISSUE: Does not work in 1.6 testing. Use patch() instead.

                  Parameters:
                  Name Type Description
                  json JSON

                  The JSON document to merge with the existing document

                  docuri string

                  The URI of the document to update

                  callback_opt function

                  The optional callback to invoke after the method completes

                  Source:

                  mergeGraph(triples, uri_opt, callback_opt)

                  Merges a set of triples in to an n-triples graph. Allows you to specify a named graph (collection) or use the default graph.

                  http://docs.marklogic.com/REST/POST/v1/graphs

                  Parameters:
                  Name Type Description
                  triples string | JSON

                  The raw N-triples (string) or JSON triples (object JSON array) to store

                  uri_opt string

                  The graph name to replace. If not provided, the default MarkLogic graph (all triples) will be merged.

                  callback_opt function

                  The optional callback to invoke after the method completes

                  Source:

                  metadata(docuri, callback_opt)

                  Fetches the metadata for a document with the given URI. Metadata document returned in result.doc

                  https://docs.marklogic.com/REST/GET/v1/documents

                  Parameters:
                  Name Type Description
                  docuri string

                  The URI of the document whose metadata you want to retrieve.

                  callback_opt function

                  The optional callback to invoke after the method completes

                  Source:

                  properties(docuri, callback_opt)

                  Fetches the properties for a document with the given URI. Properties document returned in result.doc

                  https://docs.marklogic.com/REST/GET/v1/documents

                  Parameters:
                  Name Type Description
                  docuri string

                  The URI of the document whose properties you want to retrieve.

                  callback_opt function

                  The optional callback to invoke after the method completes

                  Source:

                  removeTrigger(triggerName, triggerDatabase, callback)

                  Uses the triggers.xqy REST extension to remove a named trigger configuration from the specified triggers database

                  Parameters:
                  Name Type Description
                  triggerName string

                  The name of the trigger

                  triggerDatabase string

                  The name of the trigger database to remove the trigger from

                  callback function

                  The callback function

                  Source:

                  replaceProperty(docuri, elementSelectJSON, content, callback_opt)

                  Uses MarkLogic V7's Patch support to replace or insert a property for the specified document.

                  https://docs.marklogic.com/REST/POST/v1/documents

                  Parameters:
                  Name Type Description
                  docuri string

                  The URI of the document to patch

                  elementSelectJSON mljs.elementSelectJson

                  JSON object containing a namespaces array with prefix and ns elements, an XPath 'context' (parent of the node to replace), and a 'select' XPath (remaining XPath to select child to replace) - {namespaces: [{prefix: "myns",ns: "http://myns.org/myns"}], context: "//myns:parent", select: "myns:child[1]"}

                  content xml | text

                  The document properties context to save

                  callback_opt function

                  The optional callback to invoke after the method completes

                  Source:

                  rollbackTransaction(callback)

                  Parameters:
                  Name Type Description
                  callback function

                  The callback to invoke after the method completes

                  Source:

                  samListSchema(samurl, callback)

                  REQUIRES CURSTOM REST API EXTENSION - rdb2rdf.xqy - Adam Fowler adam.fowler@marklogic.com - List DB schema attached to an MLSAM URL endpoint.

                  Parameters:
                  Name Type Description
                  samurl string

                  The endpoint URL of the installed SAM service (uses a JDBC connection)

                  callback function

                  The callback function

                  Source:

                  samRdb2Rdf(config, callback)

                  REQUIRES CURSTOM REST API EXTENSION - rdb2rdf.xqy - Adam Fowler adam.fowler@marklogic.com - Ingests an RDBMS schema subset (limited rows per table) in to the MarkLogic Triplestore using W3C RDB2RDF direct mapping.

                  NB This method relies on ANSI DESCRIBE, COUNT and Information Schema support

                  Parameters:
                  Name Type Description
                  config JSON

                  The JSON configuration of the database segment to ingest {ingest: { database: { samurl: "http://kojak.demo.marklogic.com:8080/mlsam/mlsql", schema: "test2" }, create: { graph: "mynamedgraph" }, selection: { mode: "data", table: ["customers"], offset: 0, limit: 100, column: ["col1","col2"] } } }

                  callback function

                  The callback function

                  Source:

                  samSchemaInfo(samurl, schema, callback)

                  REQUIRES CURSTOM REST API EXTENSION - rdb2rdf.xqy - Adam Fowler adam.fowler@marklogic.com - Describe tables and relationships in the prescribed schema attached to an MLSAM URL endpoint.

                  NB This method relies on ANSI DESCRIBE, COUNT and Information Schema support

                  Parameters:
                  Name Type Description
                  samurl string

                  The endpoint URL of the installed SAM service (uses a JDBC connection)

                  schema string

                  The database schema name.

                  callback function

                  The callback function

                  Source:

                  save(jsonXmlBinary, docuri_opt, props_opt, callback_opt)

                  Saves new docs with GUID-timestamp, new docs with specified id, or updates doc with specified id NB handle json being an array of multiple docs rather than a single json doc If no docuri is specified, one is generated by using a combination of the time and a large random number.

                  https://docs.marklogic.com/REST/PUT/v1/documents

                  props_opt can be used to provide extra options. These are:-

                  • collection - The comma delimited string of the collections to add the document to

                  • contentType - The content type (MIME type) of the doc. Useful for uploaded binary documents.

                  • format - The format of the response. Either json (default if not specified) or xml.

                  • permissions - array of permission JSON objects to apply: E.g. [{role: 'secret-write', permissions: 'update|read|delete'}, ...]

                  Parameters:
                  Name Type Description
                  jsonXmlBinary json | xml | file

                  The document content to save

                  docuri_opt string

                  The optional URI of the document to create

                  props_opt JSON

                  The optional additional properties to use.

                  callback_opt function

                  The optional callback to invoke after the method completes

                  Source:

                  saveAll(doc_array, uri_array_opt, callback_opt)

                  Inserts many JSON documents. FAST aware, TRANSACTION aware.

                  Parameters:
                  Name Type Description
                  doc_array Array

                  The array of document data to store. {@see mljs.prototype.save} for valid values

                  uri_array_opt Array

                  The optional array of URIs to store the documents as. Will generate if not provided

                  callback_opt function

                  The optional callback to invoke after the method completes

                  Source:

                  saveAll2(doc_array, uri_array_opt, callback_opt)

                  Alternative saveAll function that throttles invoking MarkLogic to a maximum number of simultaneous 'parallel' requests. (JavaScript is never truly parallel)

                  NB Uses an internal rv class defined in the mljs.js file.

                  Parameters:
                  Name Type Description
                  doc_array Array

                  The array of document data to store. {@see mljs.prototype.save} for valid values

                  uri_array_opt Array

                  The optional array of URIs to store the documents as. Will generate if not provided

                  callback_opt function

                  The optional callback to invoke after the method completes

                  Source:

                  saveAllParallel()

                  Saves all documents in as parallel a fashion as possible - using multiple threads and several documents per call.

                  Source:

                  saveBasicSearch(searchname, shared, query, callback_opt)

                  REQUIRES CUSTOM REST API EXTENSION - subscribe-resource.xqy - Adam Fowler adam.fowler@marklogic.com - Save searches by name, and subscribe to alerts from them. Alerts sent to a given URL.

                  Save a query as an XML document using the default search grammar (see search:search) with a given name

                  Parameters:
                  Name Type Description
                  searchname string

                  The name of the search

                  shared boolean

                  If false, the current user's username is prepended to the search name with a hyphen

                  query string

                  The search:search compatible query using the default grammar to use for the search

                  callback_opt function

                  The optional callback to invoke after the method completes

                  Source:

                  saveCollectionSearch(searchname, shared, collection, callback_opt)

                  REQUIRES CUSTOM REST API EXTENSION - subscribe-resource.xqy - Adam Fowler adam.fowler@marklogic.com - Save searches by name, and subscribe to alerts from them. Alerts sent to a given URL.

                  Save a query that matches documents created within a collection, with a given name

                  Parameters:
                  Name Type Description
                  searchname string

                  The name of the search

                  shared boolean

                  If false, the current user's username is prepended to the search name with a hyphen

                  collection string

                  The collection to restrict search results to

                  callback_opt function

                  The optional callback to invoke after the method completes

                  Source:

                  saveExistingSearch(searchname, shared, searchdocuri, callback_opt)

                  REQUIRES CUSTOM REST API EXTENSION - subscribe-resource.xqy - Adam Fowler adam.fowler@marklogic.com - Save searches by name, and subscribe to alerts from them. Alerts sent to a given URL.

                  Save an arbitrary search (any cts:query) already stored in the database, with a given name. Enables easy referencing and activation of alerts on this search.

                  Parameters:
                  Name Type Description
                  searchname string

                  The name of the search

                  shared boolean

                  If false, the current user's username is prepended to the search name with a hyphen

                  searchdocuri string

                  The URI to copy the search document from

                  callback_opt function

                  The optional callback to invoke after the method completes

                  Source:

                  saveGeoNearSearch(searchname, shared, conSpec, latitude, longitude, radius, callback_opt)

                  REQUIRES CUSTOM REST API EXTENSION - subscribe-resource.xqy - Adam Fowler adam.fowler@marklogic.com - Save searches by name, and subscribe to alerts from them. Alerts sent to a given URL.

                  Save a geospatial search based on a point and radius from it, with a given name

                  TODO check if we need to include an alert module name in the options

                  Parameters:
                  Name Type Description
                  searchname string

                  The name of the search

                  shared boolean

                  If false, the current user's username is prepended to the search name with a hyphen

                  conSpec JSON

                  The constraint specification JSON. E.g. {type: "element",ns: "",element: "location"}

                  latitude decimal

                  The WGS84 latitude for the centre of the radius search

                  longitude decimal

                  The WGS84 longitude for the centre of the radius search

                  radius decimal

                  The radius in statue (nor nautical) miles

                  callback_opt function

                  The optional callback to invoke after the method completes

                  Source:

                  saveGraph(triples, uri_opt, params_opt, callback_opt)

                  Saves a set of triples as an n-triples graph. Allows you to specify a named graph (collection) or use the default graph.

                  http://docs.marklogic.com/REST/PUT/v1/graphs

                  I'm using an easy to interpret JSON triples format. This prevents the user of this function from having to know the n-triples format. Here is an example:- triples = [{subject: "http://someiri/#here", predicate: "http://someiri/#here", object: "http://someiri/#here"},... ]

                  Note: We assume that the 'object' if provided as JSON triples is an IRI, not a string or other primitive value. Construct your own N-triples if you need to provide raw primitive values.

                  Parameters:
                  Name Type Description
                  triples string | JSON

                  The raw N-triples (string) or JSON triples (object JSON array) to store

                  uri_opt string

                  The graph name to replace. If not provided, the default MarkLogic graph (all triples) will be replaced.

                  params_opt mljs.graphparams

                  JSON containing graph extended properties. E.g. format: "turtle"

                  callback_opt function

                  The optional callback to invoke after the method completes

                  Source:

                  saveProperties(docuri, properties, callback_opt)

                  Save the properties for a document with the given URI.

                  https://docs.marklogic.com/REST/PUT/v1/documents

                  Parameters:
                  Name Type Description
                  docuri string

                  The URI of the document whose properties you want to retrieve.

                  properties JSON

                  The JSON properties document.

                  callback_opt function

                  The optional callback to invoke after the method completes

                  Source:

                  saveSearchOptions(name, searchoptions, callback_opt)

                  Saves search options with the given name. These are referred to by mljs.structuredSearch.

                  http://docs.marklogic.com/REST/PUT/v1/config/query/*

                  For structured search options see http://docs.marklogic.com/guide/rest-dev/search#id_48838

                  Use this function in conjunction with the Search Options Builder. {@see mljs.prototype.options}

                  Parameters:
                  Name Type Description
                  name string

                  The name to install the search options under

                  searchoptions JSON | XMLDocument

                  The search options JSON object. {@see mljs.prototype.options.prototype.toJson}

                  callback_opt function

                  The optional callback to invoke after the method completes

                  Source:

                  saveSearchOptionsCheck(name, searchoptions, callback_opt)

                  Call this if you only want to save search options on versions of MarkLogic prior to V7, but want to use Combined Query if executing on V7 and above.

                  http://docs.marklogic.com/REST/PUT/v1/config/query/*

                  For structured search options see http://docs.marklogic.com/guide/rest-dev/search#id_48838

                  Use this function in conjunction with the Search Options Builder. {@see mljs.prototype.options}

                  Parameters:
                  Name Type Description
                  name string

                  The name to install the search options under

                  searchoptions JSON

                  The search options JSON object. {@see mljs.prototype.options.prototype.toJson}

                  callback_opt function

                  The optional callback to invoke after the method completes

                  Source:

                  saveTransform(name, transformbinary, type, properties_opt, callback)

                  Saves a transform to the MarkLogic REST API instance with the given name, content, type and optional properties.

                  http://docs.marklogic.com/REST/PUT/v1/config/transforms/[name]

                  Parameters:
                  Name Type Description
                  name string

                  The internal name to use for the transform

                  transformbinary binary | xmldocument

                  The binary JavaScript implementation wrapper, or XML document instance, to persist

                  type string

                  Either 'xslt' or 'xquery' or 'application/xslt+xml' or 'application/xquery' - the mime type of the transform

                  properties_opt json

                  Optional properties document for transform metadata. See documentation for a list. E.g. title, transform parameters

                  callback function

                  Callback function to call after receiving a server response

                  Source:

                  Performs a search:search via REST

                  http://docs.marklogic.com/REST/GET/v1/search

                  See supported search grammar http://docs.marklogic.com/guide/search-dev/search-api#id_41745

                  Supported values for sprops_opt:-

                  • collection - The collection to restrict search results from
                  • directory - The directory uri to restrict search results from
                  • transform - The transform to apply to the top level results object on the server
                  • format - The format of the response. json or xml. json is the default if not specified
                  Parameters:
                  Name Type Description
                  query_opt string

                  The query string. Optional. (Returns all documents if not supplied, or whatever returns from the additional-query in the json options used)

                  options_opt string

                  The name of the installed options to use. Optional. In 0.7+ can also be a JSON options document, if used against MarkLogic 7

                  start_opt positiveInteger

                  Index of the first result to return in the page. First index is 1 (not 0). Defaults to 1 if not provided.

                  sprops_opt JSON

                  Additional optional search properties

                  callback_opt function

                  The optional callback to invoke after the method completes

                  Source:

                  searchCollection(collection_opt, query_opt, options_opt, sprops_opt, callback)

                  Performs a search:search via REST. Helper method for SEARCH.

                  http://docs.marklogic.com/REST/GET/v1/search

                  See supported search grammar http://docs.marklogic.com/guide/search-dev/search-api#id_41745

                  Parameters:
                  Name Type Description
                  collection_opt string

                  The optional collection to restrict the results to

                  query_opt string

                  The optional query string

                  options_opt string

                  The optional name of the installed query options to use

                  sprops_opt JSON

                  Additional optional search properties

                  callback function

                  The callback to invoke after the method completes

                  Source:

                  searchOptions(name_opt, params_opt, callback)

                  Fetches search options, if they exist, for the given search options name

                  http://docs.marklogic.com/REST/PUT/v1/config/query/*

                  For structured serch options see http://docs.marklogic.com/guide/rest-dev/search#id_48838

                  Parameters:
                  Name Type Description
                  name_opt string

                  The name of the installed search options to retrieve as JSON. If none specified, lists them all

                  params_opt mljs.optionsparams

                  The parameters for the search options operation. E.g. {format: "xml"}

                  callback function

                  The callback to invoke after the method completes

                  Source:

                  setLogger(newlogger)

                  Set the logging object to be used by this class and all wrappers. Must provide as a minimum a debug and info method that takes a single string.

                  Parameters:
                  Name Type Description
                  newlogger object

                  The logger object to use. Must support debug, log and info methods taking single string parameters.

                  Source:

                  sparql(sparql, callback)

                  Executes the specified sparql query.

                  http://docs.marklogic.com/REST/POST/v1/graphs/sparql

                  Parameters:
                  Name Type Description
                  sparql string

                  The sparql query text

                  callback function

                  The callback to invoke after the method completes.

                  Source:

                  structuredSearch(query_opt, options_opt, sprops_opt, callback)

                  Performs a structured search.

                  http://docs.marklogic.com/REST/GET/v1/search

                  Uses structured search instead of cts:query style searches. See http://docs.marklogic.com/guide/search-dev/search-api#id_53458

                  Use this method in conjunction with the Query Builder {@see mljs.prototype.query}

                  Parameters:
                  Name Type Description
                  query_opt JSON

                  The optional structured query JSON to restrict the results by

                  options_opt string

                  The optional name of the installed query options to use

                  sprops_opt JSON

                  Additional optional search properties

                  callback function

                  The callback to invoke after the method completes

                  Source:

                  subscribe(notificationurl, searchname, detail, contenttype, callback_opt)

                  REQUIRES CUSTOM REST API EXTENSION - subscribe-resource.xqy - Adam Fowler adam.fowler@marklogic.com - Save searches by name, and subscribe to alerts from them. Alerts sent to a given URL.

                  Uses Adam Fowler's (me!) REST API extension for subscribing to searches. RESTful HTTP calls are sent with the new information to the specified url.

                  Parameters:
                  Name Type Description
                  notificationurl string

                  The RESTful URL to invoke with a PUT to send the matching document to

                  searchname string

                  The name of the search

                  detail object

                  The extra details to pass to the alert handler

                  contenttype string

                  Either json (default) or xml. If JSON, uses a basic V6 JSON configuration to convert all documents to.

                  callback_opt function

                  The optional callback to invoke after the method completes

                  Source:

                  suggest(q, options_opt, additional_properties_opt, callback)

                  Suggest query completion based on the given partial query

                  http://docs.marklogic.com/REST/GET/v1/suggest

                  Parameters:
                  Name Type Description
                  q string

                  The partial query to generate suggestions for

                  options_opt string

                  The saved query options to use

                  additional_properties_opt json

                  Extra properties as a json object. E.g. q, limit, cursor-position

                  callback function

                  The callback to invoke after the method completes

                  Source:

                  triggers(callback)

                  Uses the triggers.xqy REST extension to list all triggers for this content database's triggers database that also use code installed in the current database's modules database (double sanity check)

                  Parameters:
                  Name Type Description
                  callback function

                  The callback function

                  Source:

                  unsubscribe(notificationurl, searchname, callback_opt)

                  REQUIRES CUSTOM REST API EXTENSION - subscribe-resource.xqy - Adam Fowler adam.fowler@marklogic.com - Save searches by name, and subscribe to alerts from them. Alerts sent to a given URL.

                  Unsubscribe a notificationurl from a named search. Uses Adam Fowler's (me!) REST API extension.

                  Parameters:
                  Name Type Description
                  notificationurl string

                  The RESTful URL to invoke with a PUT to send the matching document to

                  searchname string

                  The name of the search

                  callback_opt function

                  The optional callback to invoke after the method completes

                  Source:

                  unsubscribeAndDelete(notificationurl, searchname, callback_opt)

                  REQUIRES CUSTOM REST API EXTENSION - subscribe-resource.xqy - Adam Fowler adam.fowler@marklogic.com - Save searches by name, and subscribe to alerts from them. Alerts sent to a given URL.

                  Unsubscribe from an alert and delete the underlying saved search. Convenience method.

                  Parameters:
                  Name Type Description
                  notificationurl string

                  The RESTful URL to invoke with a PUT to send the matching document to

                  searchname string

                  The name of the search

                  callback_opt function

                  The optional callback to invoke after the method completes

                  Source:

                  v7check(v6func, v7func)

                  Uses the version rest extension to verify if we're on V7+ or less than V7. First func is called if less than V7, second func called if V7 or above. Typically used internally by MLJS functions, but also potentially useful to app developers (hence being a public method)

                  Parameters:
                  Name Type Description
                  v6func function

                  The function to call if MarkLogic is Version 6 (or unknown version)

                  v7func function

                  The function to call if MarkLogic is Version 7

                  Source:

                  values(query, tuplesname, optionsname, sprops_opt, callback_opt)

                  Fetches values from a lexicon or computes 2-way co-occurence.

                  https://docs.marklogic.com/REST/GET/v1/values/*

                  Parameters:
                  Name Type Description
                  query string | JSON

                  The query string (string) or structured query (object) to use to restrict the results

                  tuplesname string

                  The name of the tuples in the installed search options to return

                  optionsname string

                  The name of the installed search options to use

                  sprops_opt JSON

                  Additional optional search properties

                  callback_opt function

                  The optional callback to invoke after the method completes

                  Source:

                  valuesCombined(search, callback)

                  Same functionality as values() but uses a combined search options and query mechanism. This requires MarkLogic V7 EA 1 or above.

                  http://docs-ea.marklogic.com/REST/POST/v1/values/*

                  For structured serch options see http://docs.marklogic.com/guide/rest-dev/search#id_48838

                  Executes the values configuration provided. The name 'shotgun' used below is not important. {@see mljs.prototype.subcollections} for an example usage.

                  Parameters:
                  Name Type Description
                  search JSON

                  The JSON structured search to use

                  callback function

                  The callback to invoke after the method completes

                  Source:

                  version(callback)

                  Requires custom rest API Extension version.xqy - Adam Fowler adam.fowler@marklogic.com - Fetches output of xdmp:version(). E.g. 7.0-1

                  Parameters:
                  Name Type Description
                  callback function

                  The callback to invoke after the method completes

                  Source:

                  whoami(callback)

                  REQUIRES CUSTOM REST API EXTENSION - whoami.xqy - Adam Fowler adam.fowler@marklogic.com - Fetches information on the name and roles of the currently logged in client api user.

                  Fetches information about the user behind the current session.

                  Useful is your webapp performs the login so your javascript doesn't know your username. Also looks up roles.

                  Parameters:
                  Name Type Description
                  callback function

                  The callback to invoke after the method completes

                  Source:

                  Type Definitions

                  dboptions

                  MLJS connection configuration database options

                  Type:
                  • Object
                  Properties:
                  Name Type Description
                  host string

                  The hostname or IP address of the MarkLogic server. Ignored for Browser use.

                  port integer

                  The port of the MarkLogic server. Ignored for Browser use.

                  adminport integer

                  The port of the MarkLogic server's admin access. Ignored for Browser use.

                  ssl boolean

                  Whether to use http or https. Ignored for browser use

                  auth string

                  How to authenticate to the server. Ignored for browser use. Valid options are "digest", "basic" and "none"

                  username string

                  Ther username to authenticate with. Ignored for browser use

                  password string

                  User's password. Ignored for browser use

                  database string

                  The database to query or create. Browser use on V8+

                  searchoptions json

                  Not used

                  fastthreads integer

                  Not used

                  fastports integer

                  Not used

                  Source:

                  elementSelectionJson

                  Which nodes to select in the XML to replace

                  Type:
                  • Object
                  Properties:
                  Name Type Description
                  namespaces mljs.elementSelectionJsonNamespaces

                  Namespaces to use prefix, ns

                  context string

                  The context parameter for the rapi:replace-insert command

                  select string

                  The selection XPath for the element (property) to replace

                  Source:

                  elementSelectionJsonNamespaces

                  Array of namespace objects, with below members

                  Type:
                  • Object
                  Properties:
                  Name Type Description
                  prefix string

                  The text prefix to use. E.g. 'xhtml'

                  ns string

                  The namespace uri. E.g. 'http://w3.org/xhtml/1999'

                  Source:

                  graphparams

                  MLJS graph functions extended configuration object.

                  Type:
                  • Object
                  Properties:
                  Name Type Description
                  format string

                  The high level format of the response, can be turtle, ntriples, n3 (TODO verify this list)

                  Source:

                  result

                  MLJS REST result wrapper object

                  Type:
                  • Object
                  Properties:
                  Name Type Description
                  doc Object

                  The document returned, if applicable. XMLDocument or JSON object instance, or text for text docs only

                  inError boolean

                  Whether the call returned an error condition

                  statusCode string

                  The HTTP response code - normally numeric, but some http servers return dot-codes

                  format string

                  The high level format of the response, can be XML, json, text, or binary

                  mime string

                  The MIME content type returned in the content type header of the response

                  Source:
                  MLJS - A JavaScript wrapper for the MarkLogic REST API
                  MarkLogic 2012-2014
                  Documentation generated by JSDoc 3.2.3-dev on Mon Jul 18 2016 09:14:12 GMT+0100 (BST) using the DocStrap template.