new mljs()
Creates an mljs instance. Aliased to new mljs().
- Source:
- Tutorials:
Classes
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_optstring The name of the transaction. If not provided, 'client-txn' will be used. Likely not safe on a multi user system.
callbackfunction The callback to invoke after the method completes
-
collect(collection, fields_opt, callback_opt)
-
Returns all documents in a collection, optionally matching against the specified fields
Parameters:
Name Type Description collectionstring The collection to list documents from
fields_optstring Not used
callback_optfunction The optional callback to invoke after the method completes
-
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_optstring The collection URI under which to retrieve the list of subcollections. Defaults to "/"
callbackfunction The callback to invoke after the method completes
-
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_optJSON The optional structured query JSON to restrict the results by
textQuery_optstring The query string. Optional. (Returns all documents if not supplied, or whatever returns from the additional-query in the json options used)
optionsdocstring The optional query options object to use (NOT the name of query options already saved)
sprops_optJSON Additional optional search properties
callbackfunction The callback to invoke after the method completes
-
commitTransaction(callback)
-
Commits the open transaction
Parameters:
Name Type Description callbackfunction The callback to invoke after the method completes
-
configure(dboptions)
-
Provide configuration information to this database. This is merged with the defaults.
Parameters:
Name Type Description dboptionsmljs.dboptions The DB Options to merge with the default options for this connection.
-
create(options_opt, callback_opt)
-
Creates the database and rest server if it does not already exist
Parameters:
Name Type Description options_optmljs.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_optfunction The optional callback to invoke after the method completes
-
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.
-
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.
-
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.
-
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.
-
createOptions()
-
Factory pattern. Creates an options object referring back to the current database connection. Useful to link to the correct logger, and db settings.
-
createQuery()
-
Factory pattern. Creates an options object referring back to the current database connection. Useful to link to the correct logger, and db settings.
-
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.
-
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.
-
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.
-
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.
-
databases(callback)
-
Lists all available databases on the server. NOTE: Uses admin port rather than content port
Parameters:
Name Type Description callbackfunction The callback to invoke after the method completes
-
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)
-
Deletes the specified document
Parameters:
Name Type Description docuristring URI of the document to delete
callback_optfunction The optional callback to invoke after the method completes
-
deleteAll(callback)
-
Deletes ALL documents and triples in the content database
Uses deleteUsingSearch()
Parameters:
Name Type Description callbackfunction The optional callback to invoke after the method completes
-
deleteGraph(uri, callback_opt)
-
Deletes the specified graph from MarkLogic Server
Parameters:
Name Type Description uristring The name of the graph to delete. Required. (Cannot be 'default')
callback_optfunction The optional callback to invoke after the method completes
-
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 searchnamestring The name of the search
callback_optfunction The optional callback to invoke after the method completes
-
deleteTransform(name, callback_opt)
-
Deletes the named transform
http://docs.marklogic.com/REST/DELETE/v1/config/transforms/[name]
Parameters:
Name Type Description namestring The internal name of the transform to delete
callback_optfunction The optional callback function
-
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_optstring The query string. Optional. (Returns all documents if not supplied, or whatever returns from the additional-query in the json options used)
options_optstring 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_optJSON Additional optional search properties
callbackfunction The optional callback to invoke after the method completes
-
destroy(callback_opt)
-
Destroys the database and rest api instance
Parameters:
Name Type Description callback_optfunction The optional callback to invoke after the method completes
-
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 collectionstring DLS collection to list documents who are members of
callbackfunction The callback to invoke after the method completes
-
dlscollections(callback)
-
REQUIRES CUSTOM REST API EXTENSION - dls.xqy - Adam Fowler adam.fowler@marklogic.com - Lists all DLS collections
Parameters:
Name Type Description callbackfunction The callback to invoke after the method completes
-
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_urisstring | Array Documents to declare as records
collectionstring New DLS collection to add documents to
callbackfunction The callback to invoke after the method completes
-
dlsrule(name, callback)
-
REQUIRES CUSTOM REST API EXTENSION - dlsrules.xqy - Adam Fowler adam.fowler@marklogic.com - Fetches DLS retention rule
Parameters:
Name Type Description namestring Name of the Rule to fetch configuration of
callbackfunction The callback to invoke after the method completes
-
dlsrules(callback)
-
REQUIRES CUSTOM REST API EXTENSION - dlsrules.xqy - Adam Fowler adam.fowler@marklogic.com - Lists all DLS retention rules
Parameters:
Name Type Description callbackfunction The callback to invoke after the method completes
-
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_optobject {method: "GET|POST|PUT|DELETE", path: "/v1/somepath?key=value&format=json"}
content_optobject undefined for GET, DELETE, json for PUT, whatever as required for POST
callback_optobject the optional callback to invoke after the method has completed
-
exists(callback)
-
Does this database exist? Returns an object, not boolean, to the callback
Parameters:
Name Type Description callbackfunction The callback function to invoke
-
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_optfunction The optional callback to invoke after the method completes
-
forceVersion(ver)
-
Forces MLJS to assume the server is a particular version (rather than try to ascertain it itself).
Parameters:
Name Type Description verstring THe version string. E.g. 6.0-3 or 7.0-1
-
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 docuristring The URI of the document to retrieve
options_optJSON Additional optional options to use
callback_optfunction The optional callback to invoke after the method completes
-
getTransform(name, callback)
-
Fetches the transform XSLT or XQuery document.
http://docs.marklogic.com/REST/GET/v1/config/transforms/[name]
Parameters:
Name Type Description namestring The name of the transform to return
callbackfunction The callback function to call. Document will be contained within the JSON result.doc parameter
-
getVersion()
-
Returns the current version string (E.g. 7.0-1) or null if version() has not yet been called.
-
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
Parameters:
Name Type Description uri_optstring 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_optmljs.graphparams JSON containing graph extended properties. E.g. format: "turtle"
callback_optfunction The optional callback to invoke after the method completes.
-
indexes(callback)
-
Checks whether the database contains indexes for all installed search options.
Parameters:
Name Type Description callbackfunction The callback to invoke after the method completes
-
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 csvdatastring The CSV text to ingest
docid_optstring The optional URI of the document to store
callback_optfunction The optional callback to invoke after the method completes
-
installTrigger(triggerJson, callback)
-
Uses the triggers.xqy REST extension to install a trigger
Parameters:
Name Type Description triggerJsonobject The trigger description JSON (as expected by the REST API)
callbackfunction The callback function
-
keyvalue(key, value, keytype_opt, callback_opt)
-
Performs a simple key-value search. Of most use to JSON programmers.
Parameters:
Name Type Description keystring The JSON key to use for document retrieval
valuestring The value of the JSON key to match against candidate documents
keytype_optstring What type to use for the key type. Defaults to 'key'. (i.e. JSON key, not element)
callback_optfunction The optional callback to invoke after the method completes
-
linkContext()
-
Links context instance to current DB (MLJS) connection instance. Replaces all create
Context() functions -
list(directory, callback_opt)
-
Lists all documents in a directory, to the specified depth (default: 1), optionally matching the specified fields
Parameters:
Name Type Description directorystring The directory URI to list documents within
callback_optfunction The optional callback to invoke after the method completes
-
listTransforms(callback)
-
List all transforms available on the REST API instance. Returns their JSON description as per the REST API documentation.
Parameters:
Name Type Description callbackfunction The callback function to invoke. Results in the JSON result.doc parameter
-
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 jsonJSON The JSON document to merge with the existing document
docuristring The URI of the document to update
callback_optfunction The optional callback to invoke after the method completes
-
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.
Parameters:
Name Type Description triplesstring | JSON The raw N-triples (string) or JSON triples (object JSON array) to store
uri_optstring The graph name to replace. If not provided, the default MarkLogic graph (all triples) will be merged.
callback_optfunction The optional callback to invoke after the method completes
-
metadata(docuri, callback_opt)
-
Fetches the metadata for a document with the given URI. Metadata document returned in result.doc
Parameters:
Name Type Description docuristring The URI of the document whose metadata you want to retrieve.
callback_optfunction The optional callback to invoke after the method completes
-
properties(docuri, callback_opt)
-
Fetches the properties for a document with the given URI. Properties document returned in result.doc
Parameters:
Name Type Description docuristring The URI of the document whose properties you want to retrieve.
callback_optfunction The optional callback to invoke after the method completes
-
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 triggerNamestring The name of the trigger
triggerDatabasestring The name of the trigger database to remove the trigger from
callbackfunction The callback function
-
replaceProperty(docuri, elementSelectJSON, content, callback_opt)
-
Uses MarkLogic V7's Patch support to replace or insert a property for the specified document.
Parameters:
Name Type Description docuristring The URI of the document to patch
elementSelectJSONmljs.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]"}
contentxml | text The document properties context to save
callback_optfunction The optional callback to invoke after the method completes
-
rollbackTransaction(callback)
-
Rolls back the open transaction.
Parameters:
Name Type Description callbackfunction The callback to invoke after the method completes
-
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 samurlstring The endpoint URL of the installed SAM service (uses a JDBC connection)
callbackfunction The callback function
-
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 configJSON 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"] } } }
callbackfunction The callback function
-
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 samurlstring The endpoint URL of the installed SAM service (uses a JDBC connection)
schemastring The database schema name.
callbackfunction The callback function
-
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 jsonXmlBinaryjson | xml | file The document content to save
docuri_optstring The optional URI of the document to create
props_optJSON The optional additional properties to use.
callback_optfunction The optional callback to invoke after the method completes
-
saveAll(doc_array, uri_array_opt, callback_opt)
-
Inserts many JSON documents. FAST aware, TRANSACTION aware.
Parameters:
Name Type Description doc_arrayArray The array of document data to store. {@see mljs.prototype.save} for valid values
uri_array_optArray The optional array of URIs to store the documents as. Will generate if not provided
callback_optfunction The optional callback to invoke after the method completes
-
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_arrayArray The array of document data to store. {@see mljs.prototype.save} for valid values
uri_array_optArray The optional array of URIs to store the documents as. Will generate if not provided
callback_optfunction The optional callback to invoke after the method completes
-
saveAllParallel()
-
Saves all documents in as parallel a fashion as possible - using multiple threads and several documents per call.
-
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 searchnamestring The name of the search
sharedboolean If false, the current user's username is prepended to the search name with a hyphen
querystring The search:search compatible query using the default grammar to use for the search
callback_optfunction The optional callback to invoke after the method completes
-
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 searchnamestring The name of the search
sharedboolean If false, the current user's username is prepended to the search name with a hyphen
collectionstring The collection to restrict search results to
callback_optfunction The optional callback to invoke after the method completes
-
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 searchnamestring The name of the search
sharedboolean If false, the current user's username is prepended to the search name with a hyphen
searchdocuristring The URI to copy the search document from
callback_optfunction The optional callback to invoke after the method completes
-
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 searchnamestring The name of the search
sharedboolean If false, the current user's username is prepended to the search name with a hyphen
conSpecJSON The constraint specification JSON. E.g. {type: "element",ns: "",element: "location"}
latitudedecimal The WGS84 latitude for the centre of the radius search
longitudedecimal The WGS84 longitude for the centre of the radius search
radiusdecimal The radius in statue (nor nautical) miles
callback_optfunction The optional callback to invoke after the method completes
-
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 triplesstring | JSON The raw N-triples (string) or JSON triples (object JSON array) to store
uri_optstring The graph name to replace. If not provided, the default MarkLogic graph (all triples) will be replaced.
params_optmljs.graphparams JSON containing graph extended properties. E.g. format: "turtle"
callback_optfunction The optional callback to invoke after the method completes
-
saveProperties(docuri, properties, callback_opt)
-
Save the properties for a document with the given URI.
Parameters:
Name Type Description docuristring The URI of the document whose properties you want to retrieve.
propertiesJSON The JSON properties document.
callback_optfunction The optional callback to invoke after the method completes
-
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 namestring The name to install the search options under
searchoptionsJSON | XMLDocument The search options JSON object. {@see mljs.prototype.options.prototype.toJson}
callback_optfunction The optional callback to invoke after the method completes
-
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 namestring The name to install the search options under
searchoptionsJSON The search options JSON object. {@see mljs.prototype.options.prototype.toJson}
callback_optfunction The optional callback to invoke after the method completes
-
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 namestring The internal name to use for the transform
transformbinarybinary | xmldocument The binary JavaScript implementation wrapper, or XML document instance, to persist
typestring Either 'xslt' or 'xquery' or 'application/xslt+xml' or 'application/xquery' - the mime type of the transform
properties_optjson Optional properties document for transform metadata. See documentation for a list. E.g. title, transform parameters
callbackfunction Callback function to call after receiving a server response
-
search(query_opt, options_opt, start_opt, sprops_opt, callback_opt)
-
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_optstring The query string. Optional. (Returns all documents if not supplied, or whatever returns from the additional-query in the json options used)
options_optstring 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_optpositiveInteger Index of the first result to return in the page. First index is 1 (not 0). Defaults to 1 if not provided.
sprops_optJSON Additional optional search properties
callback_optfunction The optional callback to invoke after the method completes
-
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_optstring The optional collection to restrict the results to
query_optstring The optional query string
options_optstring The optional name of the installed query options to use
sprops_optJSON Additional optional search properties
callbackfunction The callback to invoke after the method completes
-
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_optstring The name of the installed search options to retrieve as JSON. If none specified, lists them all
params_optmljs.optionsparams The parameters for the search options operation. E.g. {format: "xml"}
callbackfunction The callback to invoke after the method completes
-
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 newloggerobject The logger object to use. Must support debug, log and info methods taking single string parameters.
-
sparql(sparql, callback)
-
Executes the specified sparql query.
Parameters:
Name Type Description sparqlstring The sparql query text
callbackfunction The callback to invoke after the method completes.
-
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_optJSON The optional structured query JSON to restrict the results by
options_optstring The optional name of the installed query options to use
sprops_optJSON Additional optional search properties
callbackfunction The callback to invoke after the method completes
-
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 notificationurlstring The RESTful URL to invoke with a PUT to send the matching document to
searchnamestring The name of the search
detailobject The extra details to pass to the alert handler
contenttypestring Either json (default) or xml. If JSON, uses a basic V6 JSON configuration to convert all documents to.
callback_optfunction The optional callback to invoke after the method completes
-
suggest(q, options_opt, additional_properties_opt, callback)
-
Suggest query completion based on the given partial query
Parameters:
Name Type Description qstring The partial query to generate suggestions for
options_optstring The saved query options to use
additional_properties_optjson Extra properties as a json object. E.g. q, limit, cursor-position
callbackfunction The callback to invoke after the method completes
-
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 callbackfunction The callback function
-
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 notificationurlstring The RESTful URL to invoke with a PUT to send the matching document to
searchnamestring The name of the search
callback_optfunction The optional callback to invoke after the method completes
-
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 notificationurlstring The RESTful URL to invoke with a PUT to send the matching document to
searchnamestring The name of the search
callback_optfunction The optional callback to invoke after the method completes
-
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 v6funcfunction The function to call if MarkLogic is Version 6 (or unknown version)
v7funcfunction The function to call if MarkLogic is Version 7
-
values(query, tuplesname, optionsname, sprops_opt, callback_opt)
-
Fetches values from a lexicon or computes 2-way co-occurence.
Parameters:
Name Type Description querystring | JSON The query string (string) or structured query (object) to use to restrict the results
tuplesnamestring The name of the tuples in the installed search options to return
optionsnamestring The name of the installed search options to use
sprops_optJSON Additional optional search properties
callback_optfunction The optional callback to invoke after the method completes
-
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 searchJSON The JSON structured search to use
callbackfunction The callback to invoke after the method completes
-
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 callbackfunction The callback to invoke after the method completes
-
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 callbackfunction The callback to invoke after the method completes
Type Definitions
-
dboptions
-
MLJS connection configuration database options
Type:
- Object
- Source:
Properties:
Name Type Description hoststring The hostname or IP address of the MarkLogic server. Ignored for Browser use.
portinteger The port of the MarkLogic server. Ignored for Browser use.
adminportinteger The port of the MarkLogic server's admin access. Ignored for Browser use.
sslboolean Whether to use http or https. Ignored for browser use
authstring How to authenticate to the server. Ignored for browser use. Valid options are "digest", "basic" and "none"
usernamestring Ther username to authenticate with. Ignored for browser use
passwordstring User's password. Ignored for browser use
databasestring The database to query or create. Browser use on V8+
searchoptionsjson Not used
fastthreadsinteger Not used
fastportsinteger Not used
-
elementSelectionJson
-
Which nodes to select in the XML to replace
Type:
- Object
- Source:
Properties:
Name Type Description namespacesmljs.elementSelectionJsonNamespaces Namespaces to use prefix, ns
contextstring The context parameter for the rapi:replace-insert command
selectstring The selection XPath for the element (property) to replace
-
elementSelectionJsonNamespaces
-
Array of namespace objects, with below members
Type:
- Object
-
graphparams
-
MLJS graph functions extended configuration object.
Type:
- Object
-
result
-
MLJS REST result wrapper object
Type:
- Object
- Source:
Properties:
Name Type Description docObject The document returned, if applicable. XMLDocument or JSON object instance, or text for text docs only
inErrorboolean Whether the call returned an error condition
statusCodestring The HTTP response code - normally numeric, but some http servers return dot-codes
formatstring The high level format of the response, can be XML, json, text, or binary
mimestring The MIME content type returned in the content type header of the response