Class: documentcontext

mljs# documentcontext

new documentcontext()

A Document context can be used to fetch or update information on a single document in MarkLogic. E.g. fetching and updating properties. This is useful when many widgets on a page are providing different views on a document. E.g. its content, its properties or its permissions.

Deprecated:
  • use var db = new mljs(); var ctx = db.createDocumentContext(); instead of this constructor.
    Source:

    Methods

    <static> getConfigurationDefinition()

    Returns the MLJS Workplace Context Configuration definition JSON object

    Source:

    addAllowableProperty(json)

    Specifies the subject of properties to use when fetching properties.

    Parameters:
    Name Type Description
    json json

    The properties JSON to use - [{name: "keyword",title: "Keyword", cardinality: 1 | "*"}, ... ]

    Source:

    getAllowableProperties() → {Array}

    Returns an array of all allowable properties for this context.

    Source:
    Returns:

    properties - An Array of allowable properties JSON objects

    Type
    Array

    getAllowableProperty(propname) → {json}

    Fetches the property configuration for the specified allowed property name

    Parameters:
    Name Type Description
    propname string

    The property name to lookup

    Source:
    Returns:

    propertyJson - The available property JSON configuration

    Type
    json

    getContent(docuri)

    Fetches the content of the specified document uri.

    Parameters:
    Name Type Description
    docuri string

    The document

    Source:

    getFacets(docuri, optionsName)

    Loads the facets for the specified document and options. Affectively does a document-query. Requires that the options specified has a contraint named 'uriconstraint'.

    Parameters:
    Name Type Description
    docuri string

    The document

    optionsName string

    The pre saved options configuration to use

    Source:

    getFilteredContentFor(docuri)

    Finds a document with an originalurl element the same as the given URI, and then call getContent for that document.

    Parameters:
    Name Type Description
    docuri string

    The document uri

    Source:

    getPart(fieldDef)

    Returns the value of the given part, or null if it doesn't exist yet

    Parameters:
    Name Type Description
    fieldDef json

    The field definition

    Source:

    getProperties(docuri)

    Fetches all the properties for the specified docuri

    Parameters:
    Name Type Description
    docuri string

    The document

    Source:

    getTemplate()

    Returns the current template value (WARNING: May be text if set via Workplace, not an XML Document or JSON object)

    Source:

    highlight(docuri)

    Set the highlighted document to the one in the specified URI. Fires NOTHING AT THE MOMENT TODO SHOULD BE updateDocumentHighlighted

    Parameters:
    Name Type Description
    docuri string

    The URI of the document highlighted (usually hovered over)

    Source:

    patchProperty()

    TODO does nothing at the moment. Should use V6's POST /v1/document?mode=metadata to patch the properties

    Source:

    register(obj)

    Registers the specified object with this context. Introspects the object. General methods checked for: setDocumentContext Event handlers checked for: updateDocumentContent, updateDocumentProperties, updateOperation, updateDocumentFacets Events listener for: addDocumentSelectionListener, addDocumentHighlightListener

    Note that updateOperation is a general catch all that is called whenever a document or its properties are updated (to allow page elements to refresh themselves independantly)

    Parameters:
    Name Type Description
    obj object

    The object to introspect and register with this context.

    Source:

    reset()

    Resets the content of this document to null or the template value. Converts to XML or JSON automatically. Call this method when you've loaded a document, but now wish to work on a new document, without using the same URI or properties. Forces a call to updateContent()

    Source:

    save()

    Saves this document content, properties and permissions in one hit via a PUT to /v1/documents - mljs.save(). If a new document, sets the value of context._uri to the new document's URI. Forces an immediate getContent() in order to load any changes by pre-commit triggers. (This also gives you the URI via updateContent({docuri: "uri", doc: XML|JSON}); ).

    Source:

    select(docuri)

    Set the document selected.

    Parameters:
    Name Type Description
    docuri string

    The document to select

    Source:

    setConfiguration(config)

    Sets the configuration of this context using the MLJS Workplace JSON format.

    Parameters:
    Name Type Description
    config JSON

    The JSON configuration of this context.

    Source:

    setPart(fieldDef, content)

    Sets the value of a part (field aka property aka element aka attribute) within the document.

    Parameters:
    Name Type Description
    fieldDef json

    The field definition

    content string | number

    The raw JavaScript content

    Source:

    setProperties(docuri, propertyJson)

    Sets the properties (merges using V7 functionality) of the specified document uri.

    Parameters:
    Name Type Description
    docuri string

    The document

    propertyJson json

    The property JSON to use (as per the REST API)

    Source:

    setTemplate(templateContent)

    Sets the template to use for a new document. WARNING: This does NOT call reset() to clear the currently saved document!

    Parameters:
    Name Type Description
    templateContent string | XMLDocument | JSON

    The content to use in the template.

    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.