Loading TOC...


   $instance as map:map,
   $attachments as xs:string
) as map:map


This function is deprecated and will not be supported in MarkLogic 11.
A utility function used by generated code to add one or more nodes to an instance as attachments.

$instance A json:object containing the instance to which this function should add attachments.
$attachments The attachments to add to the instance. These should be XML element nodes or JSON object nodes.

Usage Notes

The input instance should be an instance node of the form produced by es:init-instance. You will not usually call this function outside of code generated by Entity Services. The generated code uses this function to add the original raw source to an instance as an attachment.

See Also


xquery version "1.0-ml";
import module namespace es = "http://marklogic.com/entity-services"
  at "/MarkLogic/entity-services/entity-services.xqy";

let $raw := fn:doc('/es-gs/raw/2345.json')
let $instance := es:init-instance(es:init-source($raw, 'Person'), 'Person')
return ($raw, es:add-attachments($instance, $raw))

(: Returns the original raw input and an instance skeleton to which
 : the raw input node and some addition user-defined data has been
 : added.
 : ( {"pid":2345, "given":"Martha", "family":"Washington"},
 :   {"$type":"Person", 
 :    "$attachments": [
 :      {"pid":2345, "given":"Martha", "family":"Washington"},
 :      "<my>extra data</my>"
 :    ]
 :   } )

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.