Loading TOC...


   $model as Object
) as Sequence


Generate entity instances of each entity type in a basic model.

$model A valid basic model.

Usage Notes

This function is useful for examining what entity instances will look like by default and for testing code that manipulates entities.

A single test entity instance is generated for each entity type defined by the input basic model. Each instance is an XML element that is a valid representation of the entity type, although it might not be exactly what an implementation your application requires.

For each property in an entity type, this function emits an element containing a dummy value of the property's type. If a property is a reference to an entity type that can be resolved local to this model, then an instance of the referenced type is embedded within the referring instance. If a property is an array, only one element of the array item type is generated, but it has a datatype attribute that indicates it is an array. See the example below.

See Also


const es = require('/MarkLogic/entity-services/entity-services');

    { "info": {
        "title": "Example",
        "version": "1.0.0",
        "description": "ES Examples"
      "definitions": {
        "Name": {
          "properties": {
            "first": { "datatype": "string" },
            "middle": { "datatype": "string" },
            "last": { "datatype": "string" }
          "required": [ "first", "last" ]
        "Person": {
          "properties": {
            "id": { "datatype": "int" },
            "name": { "$ref": "#/definitions/Name" },
            "bio": { "datatype": "string" },
            "rating": { "datatype": "float" },
            "phone": {
              "datatype": "array",
              "items": { "datatype": "string" }
          "primaryKey": "id",
          "required": [ "id", "name" ]
    } } }

/* ==> Two test instances, one for Name and one for Person. MarkLogic
       produces a Sequence of XML element nodes similar to the following.

  <first>some string</first>
  <middle>some string</middle>
  <last>some string</last>

      <first>some string</first>
      <middle>some string</middle>
      <last>some string</last>
  <bio>some string</bio>
  <phone datatype="array">some string</phone>

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