Loading TOC...

MarkLogic Server 11.0 Product Documentation
es.optional

es.optional(
   instance as Object,
   key-name as String,
   key-value as Item?
) as Object

Summary

This function is deprecated and will be removed in a future release.
Add a key-value pair to a map, if the value exists, and return the modified input map. This function is meant for use in code generated by Entity Services.

Parameters
instance A map:map representation of an entity instance.
key-name A key name.
key-value The value to which to set the key, if the value exists.

Usage Notes

This function is included for use within the modules that Entity Services generates for manipulating instance data. It is identical to map.with except map.with inserts a key with a null value in the case of an empty value. This function leaves the map unmodified if there is no value.

This function returns the original instance, with the key-value pair added.

See Also

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