es:add-attachments( $instance as map:map, $attachments as xs:string ) as map:map
This function is deprecated and will be removed in a future release.
A utility function used by generated code to add one or more
nodes to an instance as attachments.
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.
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: Get the most useful answers to questions from the MarkLogic community, or ask your own question.