Llamaverse

Loading the llamaverse

The llamaverse is a collection of documents and assets that form the base environment used to demonstrate the capabilities of MarkLogic throughout our articles.

Roles

Two base roles are created in the llamaverse. A 'llamaverse-writer' role and a 'reader' role. The 'writer' role has the ability to write to the database and the 'llamaverse-reader' role has the ability to read the assets from the llamaverse.

xquery version "1.0-ml";
import module namespace sec = "http://marklogic.com/xdmp/security" at  "/MarkLogic/security.xqy";

xdmp:invoke-function(
    function() {
        sec:create-user(
            "mother",
            "Llamaverse Creator",
            "llama",
            ("llamaverse-reader", "llamaverse-writer"),
            (),
            ()
        ),
        sec:create-user(
            "llama",
            "Llamaverse Inhabitant",
            "llama",
            ("llamaverse-reader"),
            (),
            ()
        )
    },
    <options xmlns="xdmp:eval">
        <database>{xdmp:database("Security")}</database>
    </options>
)
'use strict';
const sec = require('/MarkLogic/security.xqy');

xdmp.invokeFunction(
    () => {
        sec.createRole("llamaverse-reader", "Explore the Llamaverse", [], [], []);
        sec.createRole("llamaverse-writer", "Create the Llamaverse", [], [], ["/llamaverse"]);
    },
    {
        database: xdmp.database("Security"),
        "update": "true"
    }
);

The 'llamaverse-writer' role will be assigned with default permissions to be set on each document that is created through that role:

xquery version "1.0-ml";
import module namespace sec = "http://marklogic.com/xdmp/security" at "/MarkLogic/security.xqy";

xdmp:invoke-function(
    function() {
        sec:role-set-default-permissions(
            "llamaverse-writer",
            (
                xdmp:permission("llamaverse-reader", "read"),
                xdmp:permission("llamaverse-writer", "update")
            )
        )
    },
    <options xmlns="xdmp:eval">
        <database>{xdmp:database("Security")}</database>
    </options>
)
'use strict';
const sec = require('/MarkLogic/security.xqy');

xdmp.invokeFunction(
    () => {
        sec.roleSetDefaultPermissions(
            "llamaverse-writer",
            [
                xdmp.permission("llamaverse-reader", "read", "element"),
                xdmp.permission("llamaverse-writer", "update", "element")
            ]
        )
    },
    {
        "database": xdmp.database("Security"),
        "update": "true"
    }
);

Basic privileges are added to the 'llamaverse-writer' role to allow for the creation of documents and assets in the llamaverse:

xquery version "1.0-ml";
import module namespace sec = "http://marklogic.com/xdmp/security" at "/MarkLogic/security.xqy";

xdmp:invoke-function(
    function() {
        sec:privilege-add-roles(
            "http://marklogic.com/xdmp/privileges/unprotected-collections",
            "execute",
            ("llamaverse-writer")
        ),
        sec:privilege-add-roles(
            "http://marklogic.com/xdmp/privileges/xdmp-eval",
            "execute",
            ("llamaverse-writer")
        ),
        sec:privilege-add-roles(
            "http://marklogic.com/xdmp/privileges/xdmp-eval-in",
            "execute",
            ("llamaverse-writer")
        )
    },
    <options xmlns="xdmp:eval">
        <database>{xdmp:database("Security")}</database>
    </options>
)
'use strict';
const sec = require('/MarkLogic/security.xqy');

xdmp.invokeFunction(
    () => {
        sec.privilegeAddRoles(
            'http://marklogic.com/xdmp/privileges/unprotected-collections',
            'execute',
            ['llamaverse-writer']
        );
        sec.privilegeAddRoles(
            'http://marklogic.com/xdmp/privileges/xdmp-eval',
            'execute',
            ['llamaverse-writer']
        );
        sec.privilegeAddRoles(
            'http://marklogic.com/xdmp/privileges/xdmp-eval-in',
            'execute',
            ['llamaverse-writer']
        );
    },
    {
        "database": xdmp.database('Security'),
        "update": "true"
    }
);

A URI privilege is created and added to the 'llamaverse-writer' role to protect documents in the llamaverse:

xquery version "1.0-ml";
import module namespace sec = "http://marklogic.com/xdmp/security" at "/MarkLogic/security.xqy";

xdmp:invoke-function(
    function() {
        sec:create-privilege("llamaverse", "/llamaverse/", "uri", "llamaverse-writer")
    },
    <options xmlns="xdmp:eval">
        <database>{xdmp:database("Security")}</database>
    </options>
)
'use strict';
const sec = require('/MarkLogic/security.xqy');

xdmp.invokeFunction(
    () => {
        sec.createPrivilege('llamaverse', '/llamaverse/', 'uri', ['llamaverse-writer'])
    },
    {
        "database": xdmp.database("Security"),
        "update": "true"
    }
);

Users

The llamaverse has two users, 'mother' and 'llama'. The 'mother' user has the 'llamaverse-writer' role and the 'llama' user has the 'llamaverse-reader' role:

xquery version "1.0-ml";
import module namespace sec = "http://marklogic.com/xdmp/security" at  "/MarkLogic/security.xqy";

xdmp:invoke-function(
    function() {
        sec:create-user(
            "mother",
            "Llamaverse Creator",
            "llama",
            ("llamaverse-reader", "llamaverse-writer"),
            (),
            ()
        ),
        sec:create-user(
            "llama",
            "Llamaverse Inhabitant",
            "llama",
            ("llamaverse-reader"),
            (),
            ()
        )
    },
    <options xmlns="xdmp:eval">
        <database>{xdmp:database("Security")}</database>
    </options>
)
'use strict';
const sec = require('/MarkLogic/security.xqy');

xdmp.invokeFunction(
    () => {
        sec.createUser(
            "mother",
            "Llamaverse Creator",
            "llama",
            ["llamaverse-reader", "llamaverse-writer"],
            [],
            []
        );
        sec.createUser(
            "llama",
            "Llamaverse Inhabitant",
            "llama",
            ["llamaverse-reader"],
            [],
            []
        );
    },
    {
        "database": xdmp.database("Security"),
        "update": "true"
    }
);

TDE Templates

The llamaverse has TDE templates that are used to create a view on the data in the llamaverse. The following TDE templates are created:

Llamas

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

let $template := 
    <template xmlns="http://marklogic.com/xdmp/tde">
        <context>/envelope/instance</context>
        <collections>
            <collections-and>
                <collection>/llamaverse/llamas</collection>
            </collections-and>
        </collections>
        <rows>
            <row>
                <schema-name>llamaverse</schema-name>
                <view-name>llamas</view-name>
                <columns>
                    <column>
                        <name>id</name>
                        <scalar-type>int</scalar-type>
                        <val>id</val>
                    </column>
                    <column>
                        <name>name</name>
                        <scalar-type>string</scalar-type>
                        <val>name</val>
                    </column>
                    <column>
                        <name>farm</name>
                        <scalar-type>int</scalar-type>
                        <val>farm</val>
                    </column>
                </columns>
            </row>
        </rows>
    </template>

return tde:template-insert(
    "/llamaverse/llamas.xml",
    $template,
    (
        xdmp:permission("llamaverse-reader", "read"),
        xdmp:permission("llamaverse-writer", "update")
    )
)
'use strict';
const tde = require("/MarkLogic/tde.xqy");

const template = {
    "template": {
        "context": "/envelope/instance",
        "collections":[
            { "collectionsAnd": ["/llamaverse/llamas"] }
        ],
        "rows": [
            {
                "schemaName": "llamaverse",
                "viewName": "llamas",
                "columns": [
                    {
                        "name": "id",
                        "scalarType": "int",
                        "val": "id"
                    },
                    {
                        "name": "name",
                        "scalarType": "string",
                        "val": "name"
                    },
                    {
                        "name": "farm",
                        "scalarType": "int",
                        "val": "farm"
                    }
                ]
            }
        ]
    }
};

xdmp.invokeFunction(
    () => {
        return tde.templateInsert(
            "/llamaverse/llamas.json",
            template,
            [
                xdmp.permission("llamaverse-reader", "read"),
                xdmp.permission("llamaverse-writer", "update")
            ]
        );
    },
    {
        "update": "true"
    }
);

Farms

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

let $template := 
    <template xmlns="http://marklogic.com/xdmp/tde">
        <context>/envelope/instance</context>
        <collections>
            <collections-and>
                <collection>/llamaverse/llamas</collection>
            </collections-and>
        </collections>
        <rows>
            <row>
                <schema-name>llamaverse</schema-name>
                <view-name>llamas</view-name>
                <columns>
                    <column>
                        <name>id</name>
                        <scalar-type>int</scalar-type>
                        <val>id</val>
                    </column>
                    <column>
                        <name>name</name>
                        <scalar-type>string</scalar-type>
                        <val>name</val>
                    </column>
                    <column>
                        <name>farm</name>
                        <scalar-type>int</scalar-type>
                        <val>farm</val>
                    </column>
                </columns>
            </row>
        </rows>
    </template>

return tde:template-insert(
    "/llamaverse/llamas.xml",
    $template,
    (
        xdmp:permission("llamaverse-reader", "read"),
        xdmp:permission("llamaverse-writer", "update")
    )
)
'use strict';
const tde = require("/MarkLogic/tde.xqy");

const template = {
    "template": {
        "context": "/envelope/instance",
        "collections":[
            { "collectionsAnd": ["/llamaverse/llamas"] }
        ],
        "rows": [
            {
                "schemaName": "llamaverse",
                "viewName": "llamas",
                "columns": [
                    {
                        "name": "id",
                        "scalarType": "int",
                        "val": "id"
                    },
                    {
                        "name": "name",
                        "scalarType": "string",
                        "val": "name"
                    },
                    {
                        "name": "farm",
                        "scalarType": "int",
                        "val": "farm"
                    }
                ]
            }
        ]
    }
};

xdmp.invokeFunction(
    () => {
        return tde.templateInsert(
            "/llamaverse/llamas.json",
            template,
            [
                xdmp.permission("llamaverse-reader", "read"),
                xdmp.permission("llamaverse-writer", "update")
            ]
        );
    },
    {
        "update": "true"
    }
);

Pastures

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

let $template := 
    <template xmlns="http://marklogic.com/xdmp/tde">
        <context>/envelope/instance</context>
        <collections>
            <collections-and>
                <collection>/llamaverse/llamas</collection>
            </collections-and>
        </collections>
        <rows>
            <row>
                <schema-name>llamaverse</schema-name>
                <view-name>llamas</view-name>
                <columns>
                    <column>
                        <name>id</name>
                        <scalar-type>int</scalar-type>
                        <val>id</val>
                    </column>
                    <column>
                        <name>name</name>
                        <scalar-type>string</scalar-type>
                        <val>name</val>
                    </column>
                    <column>
                        <name>farm</name>
                        <scalar-type>int</scalar-type>
                        <val>farm</val>
                    </column>
                </columns>
            </row>
        </rows>
    </template>

return tde:template-insert(
    "/llamaverse/llamas.xml",
    $template,
    (
        xdmp:permission("llamaverse-reader", "read"),
        xdmp:permission("llamaverse-writer", "update")
    )
)
'use strict';
const tde = require("/MarkLogic/tde.xqy");

const template = {
    "template": {
        "context": "/envelope/instance",
        "collections":[
            { "collectionsAnd": ["/llamaverse/llamas"] }
        ],
        "rows": [
            {
                "schemaName": "llamaverse",
                "viewName": "llamas",
                "columns": [
                    {
                        "name": "id",
                        "scalarType": "int",
                        "val": "id"
                    },
                    {
                        "name": "name",
                        "scalarType": "string",
                        "val": "name"
                    },
                    {
                        "name": "farm",
                        "scalarType": "int",
                        "val": "farm"
                    }
                ]
            }
        ]
    }
};

xdmp.invokeFunction(
    () => {
        return tde.templateInsert(
            "/llamaverse/llamas.json",
            template,
            [
                xdmp.permission("llamaverse-reader", "read"),
                xdmp.permission("llamaverse-writer", "update")
            ]
        );
    },
    {
        "update": "true"
    }
);

Documents

Some documents are created in the llamaverse to demonstrate the capabilities of MarkLogic. The following documents are created:

Llamas

xquery version "1.0-ml";

let $data := xdmp:to-json(xdmp:from-json-string('[
  {
    "envelope": {
      "instance": {
        "id": 1,
        "name": "George",
        "type": "llama",
        "birthDate": "2007-06-01",
        "farm": 3,
        "geometry": {
          "coordinates": [-121.97416315360529, 37.37726523951736],
          "type": "Point"
        }
      }
    }
  },
  {
    "envelope": {
      "instance": {
        "id": 2,
        "name": "Charlie",
        "type": "llama",
        "birthDate": "2002-06-10",
        "farm": 3,
        "geometry": {
          "coordinates": [-121.97395784953005, 37.37715161987822],
          "type": "Point"
        }
      }
    }
  },
  {
    "envelope": {
      "instance": {
        "id": 3,
        "name": "Winnie",
        "type": "llama",
        "birthDate": "1998-11-22",
        "farm": 3,
        "geometry": {
          "coordinates": [-121.97345925391895, 37.37734098584815],
          "type": "Point"
        }
      }
    }
  },
  {
    "envelope": {
      "instance": {
        "id": 4,
        "name": "Loretta",
        "type": "llama",
        "birthDate": "1996-11-14",
        "farm": 3,
        "geometry": {
          "coordinates": [-121.97352891065863, 37.37674375308745],
          "type": "Point"
        }
      }
    }
  },
  {
    "envelope": {
      "instance": {
        "id": 5,
        "name": "Pablo",
        "type": "llama",
        "birthDate": "2003-11-11",
        "farm": 1,
        "geometry": {
          "coordinates": [-121.97599622570581, 37.377279806127106],
          "type": "Point"
        }
      }
    }
  },
  {
    "envelope": {
      "instance": {
        "id": 6,
        "name": "Maria",
        "type": "llama",
        "birthDate": "2003-05-26",
        "farm": 1,
        "geometry": {
          "coordinates": [-121.97590090595644, 37.37722445300167],
          "type": "Point"
        }
      }
    }
  },
  {
    "envelope": {
      "instance": {
        "id": 7,
        "name": "Jeff",
        "type": "llama",
        "birthDate": "2003-05-11",
        "farm": 1,
        "geometry": {
          "coordinates": [-121.97704474294699, 37.376936033423746],
          "type": "Point"
        }
      }
    }
  },
  {
    "envelope": {
      "instance": {
        "id": 8,
        "name": "Tiff",
        "type": "llama",
        "birthDate": "2002-03-20",
        "farm": 1,
        "geometry": {
          "coordinates": [-121.97694209090955, 37.37683989331836],
          "type": "Point"
        }
      }
    }
  },
  {
    "envelope": {
      "instance": {
        "id": 9,
        "name": "Larry",
        "type": "llama",
        "birthDate": "2005-10-02",
        "farm": 1,
        "geometry": {
          "coordinates": [-121.97705207523538, 37.37679036654879],
          "type": "Point"
        }
      }
    }
  },
  {
    "envelope": {
      "instance": {
        "id": 10,
        "name": "Duke",
        "type": "llama",
        "birthDate": "2005-09-28",
        "farm": 2,
        "geometry": {
          "coordinates": [-121.97479373040784, 37.37533659563674],
          "type": "Point"
        }
      }
    }
  },
  {
    "envelope": {
      "instance": {
        "id": 11,
        "name": "Elle",
        "type": "llama",
        "birthDate": "2005-03-24",
        "farm": 2,
        "geometry": {
          "coordinates": [-121.97382220219458, 37.375418170702574],
          "type": "Point"
        }
      }
    }
  },
  {
    "envelope": {
      "instance": {
        "id": 12,
        "name": "Chip",
        "type": "llama",
        "birthDate": "1999-04-12",
        "farm": 2,
        "geometry": {
          "coordinates": [-121.97337859874628, 37.37568328905425],
          "type": "Point"
        }
      }
    }
  },
  {
    "envelope": {
      "instance": {
        "id": 13,
        "name": "Beth",
        "type": "llama",
        "birthDate": "1999-10-19",
        "farm": 2,
        "geometry": {
          "coordinates": [-121.97371588401279, 37.375706596117254],
          "type": "Point"
        }
      }
    }
  },
  {
    "envelope": {
      "instance": {
        "id": 14,
        "name": "Ruby",
        "type": "llama",
        "birthDate": "2000-06-04",
        "farm": 2,
        "geometry": {
          "coordinates": [-121.97337126645787, 37.37549391889877],
          "type": "Point"
        }
      }
    }
  },
  {
    "envelope": {
      "instance": {
        "id": 15,
        "name": "James",
        "type": "llama",
        "birthDate": "2000-07-01",
        "farm": 3,
        "geometry": {
          "coordinates": [-121.97734903291558, 37.37544439124045],
          "type": "Point"
        }
      }
    }
  },
  {
    "envelope": {
      "instance": {
        "id": 16,
        "name": "William",
        "type": "llama",
        "birthDate": "2002-08-15",
        "farm": 3,
        "geometry": {
          "coordinates": [-121.97714739498474, 37.37532785544573],
          "type": "Point"
        }
      }
    }
  },
  {
    "envelope": {
      "instance": {
        "id": 17,
        "name": "Haley",
        "type": "llama",
        "birthDate": "2003-06-22",
        "farm": 3,
        "geometry": {
          "coordinates": [-121.97340426175577, 37.37689816006372],
          "type": "Point"
        }
      }
    }
  },
  {
    "envelope": {
      "instance": {
        "id": 18,
        "name": "Ben",
        "type": "llama",
        "birthDate": "2004-01-22",
        "farm": 3,
        "geometry": {
          "coordinates": [-121.97329061128559, 37.37680201990919],
          "type": "Point"
        }
      }
    }
  },
  {
    "envelope": {
      "instance": {
        "id": 19,
        "name": "Adam",
        "type": "llama",
        "birthDate": "2004-12-10",
        "farm": 1,
        "geometry": {
          "coordinates": [-121.97639583542347, 37.37706130670982],
          "type": "Point"
        }
      }
    }
  },
  {
    "envelope": {
      "instance": {
        "id": 20,
        "name": "Jenny",
        "type": "llama",
        "birthDate": "2000-08-11",
        "farm": 1,
        "geometry": {
          "coordinates": [-121.97588624137967, 37.37635627758419],
          "type": "Point"
        }
      }
    }
  },
  {
    "envelope": {
      "instance": {
        "id": 21,
        "name": "Mick",
        "type": "llama",
        "birthDate": "2005-02-06",
        "farm": 1,
        "geometry": {
          "coordinates": [-121.97574692790832, 37.37632714400462],
          "type": "Point"
        }
      }
    }
  },
  {
    "envelope": {
      "instance": {
        "id": 22,
        "name": "Lizzy",
        "type": "llama",
        "birthDate": "2005-03-22",
        "farm": 1,
        "geometry": {
          "coordinates": [-121.97576504912091, 37.37653998535161],
          "type": "Point"
        }
      }
    }
  }
]'))

return
    for $doc in $data/*
    return xdmp:invoke-function(
        function() {
            xdmp:document-insert(
                "/llamaverse/llama/" || sem:uuid-string() || ".json",
                $doc,
                <options xmlns="xdmp:document-insert">  
                    <permissions>{xdmp:default-permissions()}</permissions>
                    <collections>{
                      <collection>/type/llama</collection>,
                      for $coll in xdmp:default-collections()
                      return <collection>{$coll}</collection>
                    }</collections>
                </options>
            )
        },
        map:entry("userId", xdmp:user("mother"))
            => map:with("update", "true")
            => map:with("isolation", "different-transaction") 
    )
'use strict';

const data = [
    {
        "envelope": {
            "instance": {
                "id": 1,
                "name": "George",
                "type": "llama",
                "birthDate": "2007-06-01",
                "farm": 3,
                "geometry": {
                    "coordinates": [-121.97416315360529, 37.37726523951736],
                    "type": "Point"
                }
            }
        }
    },
    {
        "envelope": {
            "instance": {
                "id": 2,
                "name": "Charlie",
                "type": "llama",
                "birthDate": "2002-06-10",
                "farm": 3,
                "geometry": {
                    "coordinates": [-121.97395784953005, 37.37715161987822],
                    "type": "Point"
                }
            }
        }
    },
    {
        "envelope": {
            "instance": {
                "id": 3,
                "name": "Winnie",
                "type": "llama",
                "birthDate": "1998-11-22",
                "farm": 3,
                "geometry": {
                    "coordinates": [-121.97345925391895, 37.37734098584815],
                    "type": "Point"
                }
            }
        }
    },
    {
        "envelope": {
            "instance": {
                "id": 4,
                "name": "Loretta",
                "type": "llama",
                "birthDate": "1996-11-14",
                "farm": 3,
                "geometry": {
                    "coordinates": [-121.97352891065863, 37.37674375308745],
                    "type": "Point"
                }
            }
        }
    },
    {
        "envelope": {
            "instance": {
                "id": 5,
                "name": "Pablo",
                "type": "llama",
                "birthDate": "2003-11-11",
                "farm": 1,
                "geometry": {
                    "coordinates": [-121.97599622570581, 37.377279806127106],
                    "type": "Point"
                }
            }
        }
    },
    {
        "envelope": {
            "instance": {
                "id": 6,
                "name": "Maria",
                "type": "llama",
                "birthDate": "2003-05-26",
                "farm": 1,
                "geometry": {
                    "coordinates": [-121.97590090595644, 37.37722445300167],
                    "type": "Point"
                }
            }
        }
    },
    {
        "envelope": {
            "instance": {
                "id": 7,
                "name": "Jeff",
                "type": "llama",
                "birthDate": "2003-05-11",
                "farm": 1,
                "geometry": {
                    "coordinates": [-121.97704474294699, 37.376936033423746],
                    "type": "Point"
                }
            }
        }
    },
    {
        "envelope": {
            "instance": {
                "id": 8,
                "name": "Tiff",
                "type": "llama",
                "birthDate": "2002-03-20",
                "farm": 1,
                "geometry": {
                    "coordinates": [-121.97694209090955, 37.37683989331836],
                    "type": "Point"
                }
            }
        }
    },
    {
        "envelope": {
            "instance": {
                "id": 9,
                "name": "Larry",
                "type": "llama",
                "birthDate": "2005-10-02",
                "farm": 1,
                "geometry": {
                    "coordinates": [-121.97705207523538, 37.37679036654879],
                    "type": "Point"
                }
            }
        }
    },
    {
        "envelope": {
            "instance": {
                "id": 10,
                "name": "Duke",
                "type": "llama",
                "birthDate": "2005-09-28",
                "farm": 2,
                "geometry": {
                    "coordinates": [-121.97479373040784, 37.37533659563674],
                    "type": "Point"
                }
            }
        }
    },
    {
        "envelope": {
            "instance": {
                "id": 11,
                "name": "Elle",
                "type": "llama",
                "birthDate": "2005-03-24",
                "farm": 2,
                "geometry": {
                    "coordinates": [-121.97382220219458, 37.375418170702574],
                    "type": "Point"
                }
            }
        }
    },
    {
        "envelope": {
            "instance": {
                "id": 12,
                "name": "Chip",
                "type": "llama",
                "birthDate": "1999-04-12",
                "farm": 2,
                "geometry": {
                    "coordinates": [-121.97337859874628, 37.37568328905425],
                    "type": "Point"
                }
            }
        }
    },
    {
        "envelope": {
            "instance": {
                "id": 13,
                "name": "Beth",
                "type": "llama",
                "birthDate": "1999-10-19",
                "farm": 2,
                "geometry": {
                    "coordinates": [-121.97371588401279, 37.375706596117254],
                    "type": "Point"
                }
            }
        }
    },
    {
        "envelope": {
            "instance": {
                "id": 14,
                "name": "Ruby",
                "type": "llama",
                "birthDate": "2000-06-04",
                "farm": 2,
                "geometry": {
                    "coordinates": [-121.97337126645787, 37.37549391889877],
                    "type": "Point"
                }
            }
        }
    },
    {
        "envelope": {
            "instance": {
                "id": 15,
                "name": "James",
                "type": "llama",
                "birthDate": "2000-07-01",
                "farm": 3,
                "geometry": {
                    "coordinates": [-121.97734903291558, 37.37544439124045],
                    "type": "Point"
                }
            }
        }
    },
    {
        "envelope": {
            "instance": {
                "id": 16,
                "name": "William",
                "type": "llama",
                "birthDate": "2002-08-15",
                "farm": 3,
                "geometry": {
                    "coordinates": [-121.97714739498474, 37.37532785544573],
                    "type": "Point"
                }
            }
        }
    },
    {
        "envelope": {
            "instance": {
                "id": 17,
                "name": "Haley",
                "type": "llama",
                "birthDate": "2003-06-22",
                "farm": 3,
                "geometry": {
                    "coordinates": [-121.97340426175577, 37.37689816006372],
                    "type": "Point"
                }
            }
        }
    },
    {
        "envelope": {
            "instance": {
                "id": 18,
                "name": "Ben",
                "type": "llama",
                "birthDate": "2004-01-22",
                "farm": 3,
                "geometry": {
                    "coordinates": [-121.97329061128559, 37.37680201990919],
                    "type": "Point"
                }
            }
        }
    },
    {
        "envelope": {
            "instance": {
                "id": 19,
                "name": "Adam",
                "type": "llama",
                "birthDate": "2004-12-10",
                "farm": 1,
                "geometry": {
                    "coordinates": [-121.97639583542347, 37.37706130670982],
                    "type": "Point"
                }
            }
        }
    },
    {
        "envelope": {
            "instance": {
                "id": 20,
                "name": "Jenny",
                "type": "llama",
                "birthDate": "2000-08-11",
                "farm": 1,
                "geometry": {
                    "coordinates": [-121.97588624137967, 37.37635627758419],
                    "type": "Point"
                }
            }
        }
    },
    {
        "envelope": {
            "instance": {
                "id": 21,
                "name": "Mick",
                "type": "llama",
                "birthDate": "2005-02-06",
                "farm": 1,
                "geometry": {
                    "coordinates": [-121.97574692790832, 37.37632714400462],
                    "type": "Point"
                }
            }
        }
    },
    {
        "envelope": {
            "instance": {
                "id": 22,
                "name": "Lizzy",
                "type": "llama",
                "birthDate": "2005-03-22",
                "farm": 1,
                "geometry": {
                    "coordinates": [-121.97576504912091, 37.37653998535161],
                    "type": "Point"
                }
            }
        }
    }
];
data.forEach((doc) => {
    xdmp.invokeFunction(
        () => {
            xdmp.documentInsert(
                `/llamaverse/llama/${sem.uuidString()}.json`,
                doc,
                {
                    permissions: xdmp.defaultPermissions(),
                    collections: xdmp.defaultCollections().toArray().concat(['/llamaverse/llamas']),
                }
            )
        },
        {
            "userId": xdmp.user("mother"),
            "update": "true",
            "isolation": "different-transaction"
        }
    )
});

Farms

xquery version "1.0-ml";

let $data := xdmp:to-json(xdmp:from-json-string('[
    {
        "envelope": {
            "instance": {
                "id": 1,
                "name": "High Hill Farm",
                "type": "farm",
                "geometry": {
                    "coordinates": [
                        [
                            [-121.975007, 37.377458],
                            [-121.975093, 37.377133],
                            [-121.974831, 37.377089],
                            [-121.974745, 37.377414],
                            [-121.975007, 37.377458]
                        ]
                    ],
                    "type": "Polygon"
                }
            }
        }
    },
    {
        "envelope": {
            "instance": {
                "id": 2,
                "name": "Blackwater Ranch",
                "type": "farm",
                "geometry": {
                    "coordinates": [
                        [
                            [-121.97415, 37.376206],
                            [-121.974592, 37.376036],
                            [-121.974462, 37.375821],
                            [-121.97402, 37.37599],
                            [-121.97415, 37.376206]
                        ]
                    ],
                    "type": "Polygon"
                }
            }
        }
    },
    {
        "envelope": {
            "instance": {
                "id": 3,
                "name": "Llama Valley Estate",
                "type": "farm",
                "geometry": {
                    "coordinates": [
                        [
                            [-121.975961, 37.375881],
                            [-121.976447, 37.375828],
                            [-121.976406, 37.375591],
                            [-121.97592, 37.375644],
                            [-121.975961, 37.375881]
                        ]
                    ],
                    "type": "Polygon"
                }
            }
        }
    }
]'))

return
    for $doc in $data/*
    return xdmp:invoke-function(
        function() {
            xdmp:document-insert(
                "/llamaverse/farm/" || sem:uuid-string() || ".json",
                $doc,
                <options xmlns="xdmp:document-insert">  
                    <permissions>{xdmp:default-permissions()}</permissions>
                    <collections>{
                      <collection>/type/farm</collection>,
                      for $coll in xdmp:default-collections()
                      return <collection>{$coll}</collection>
                    }</collections>
                </options>
            )
        },
        map:entry("userId", xdmp:user("mother"))
            => map:with("update", "true")
            => map:with("isolation", "different-transaction") 
    )
'use strict';

const data = [
    {
        "envelope": {
            "instance": {
                "id": 1,
                "name": "High Hill Farm",
                "type": "farm",
                "geometry": {
                    "coordinates": [
                        [
                            [-121.975007, 37.377458],
                            [-121.975093, 37.377133],
                            [-121.974831, 37.377089],
                            [-121.974745, 37.377414],
                            [-121.975007, 37.377458]
                        ]
                    ],
                    "type": "Polygon"
                }
            }
        }
    },
    {
        "envelope": {
            "instance": {
                "id": 2,
                "name": "Blackwater Ranch",
                "type": "farm",
                "geometry": {
                    "coordinates": [
                        [
                            [-121.97415, 37.376206],
                            [-121.974592, 37.376036],
                            [-121.974462, 37.375821],
                            [-121.97402, 37.37599],
                            [-121.97415, 37.376206]
                        ]
                    ],
                    "type": "Polygon"
                }
            }
        }
    },
    {
        "envelope": {
            "instance": {
                "id": 3,
                "name": "Llama Valley Estate",
                "type": "farm",
                "geometry": {
                    "coordinates": [
                        [
                            [-121.975961, 37.375881],
                            [-121.976447, 37.375828],
                            [-121.976406, 37.375591],
                            [-121.97592, 37.375644],
                            [-121.975961, 37.375881]
                        ]
                    ],
                    "type": "Polygon"
                }
            }
        }
    }
];
data.forEach((doc) => {
    xdmp.invokeFunction(
        () => {
            xdmp.documentInsert(
                `/llamaverse/farm/${sem.uuidString()}.json`,
                doc,
                {
                    permissions: xdmp.defaultPermissions(),
                    collections: xdmp.defaultCollections().toArray().concat(['/llamaverse/farms']),
                }
            )
        },
        {
            "userId": xdmp.user("mother"),
            "update": "true",
            "isolation": "different-transaction"
        }
    )
});

Pastures

xquery version "1.0-ml";

let $data := xdmp:to-json(xdmp:from-json-string('[
    {
        "envelope": {
            "instance": {
                "id": 1,
                "name": "High Hill Field",
                "type": "pasture",
                "farm": 1,
                "geometry": {
                    "coordinates": [
                        [
                            [
                                -121.975305,
                                37.377548
                            ],
                            [
                                -121.976849,
                                37.377548
                            ],
                            [
                                -121.976869,
                                37.377513
                            ],
                            [
                                -121.976919,
                                37.37743
                            ],
                            [
                                -121.976962,
                                37.37736
                            ],
                            [
                                -121.977011,
                                37.377287
                            ],
                            [
                                -121.977049,
                                37.377232
                            ],
                            [
                                -121.977075,
                                37.377197
                            ],
                            [
                                -121.977101,
                                37.377163
                            ],
                            [
                                -121.977126,
                                37.377133
                            ],
                            [
                                -121.977151,
                                37.377105
                            ],
                            [
                                -121.977174,
                                37.377081
                            ],
                            [
                                -121.977186,
                                37.377071
                            ],
                            [
                                -121.977195,
                                37.377063
                            ],
                            [
                                -121.977217,
                                37.377047
                            ],
                            [
                                -121.97724,
                                37.377032
                            ],
                            [
                                -121.977264,
                                37.377016
                            ],
                            [
                                -121.97729,
                                37.377001
                            ],
                            [
                                -121.977317,
                                37.376987
                            ],
                            [
                                -121.977358,
                                37.376966
                            ],
                            [
                                -121.977414,
                                37.376941
                            ],
                            [
                                -121.977468,
                                37.376918
                            ],
                            [
                                -121.977518,
                                37.376899
                            ],
                            [
                                -121.977561,
                                37.376883
                            ],
                            [
                                -121.977579,
                                37.376876
                            ],
                            [
                                -121.977579,
                                37.376176
                            ],
                            [
                                -121.977534,
                                37.376159
                            ],
                            [
                                -121.977391,
                                37.376106
                            ],
                            [
                                -121.977261,
                                37.376059
                            ],
                            [
                                -121.977174,
                                37.376029
                            ],
                            [
                                -121.977095,
                                37.376003
                            ],
                            [
                                -121.977045,
                                37.375988
                            ],
                            [
                                -121.977017,
                                37.37598
                            ],
                            [
                                -121.977005,
                                37.375977
                            ],
                            [
                                -121.97698,
                                37.375972
                            ],
                            [
                                -121.976934,
                                37.375963
                            ],
                            [
                                -121.976893,
                                37.375958
                            ],
                            [
                                -121.976859,
                                37.375955
                            ],
                            [
                                -121.976831,
                                37.375953
                            ],
                            [
                                -121.97681,
                                37.375953
                            ],
                            [
                                -121.976791,
                                37.375953
                            ],
                            [
                                -121.976787,
                                37.375954
                            ],
                            [
                                -121.976756,
                                37.375956
                            ],
                            [
                                -121.976677,
                                37.375962
                            ],
                            [
                                -121.976578,
                                37.375971
                            ],
                            [
                                -121.976464,
                                37.375982
                            ],
                            [
                                -121.976338,
                                37.375996
                            ],
                            [
                                -121.976203,
                                37.376012
                            ],
                            [
                                -121.976063,
                                37.376031
                            ],
                            [
                                -121.975921,
                                37.376051
                            ],
                            [
                                -121.97578,
                                37.376073
                            ],
                            [
                                -121.975678,
                                37.37609
                            ],
                            [
                                -121.975612,
                                37.376102
                            ],
                            [
                                -121.975548,
                                37.376114
                            ],
                            [
                                -121.975487,
                                37.376127
                            ],
                            [
                                -121.97543,
                                37.37614
                            ],
                            [
                                -121.975376,
                                37.376153
                            ],
                            [
                                -121.975326,
                                37.376166
                            ],
                            [
                                -121.97528,
                                37.376179
                            ],
                            [
                                -121.97524,
                                37.376193
                            ],
                            [
                                -121.975205,
                                37.376207
                            ],
                            [
                                -121.975182,
                                37.376217
                            ],
                            [
                                -121.975169,
                                37.376224
                            ],
                            [
                                -121.975157,
                                37.376231
                            ],
                            [
                                -121.975147,
                                37.376238
                            ],
                            [
                                -121.975139,
                                37.376245
                            ],
                            [
                                -121.975133,
                                37.376252
                            ],
                            [
                                -121.975128,
                                37.37626
                            ],
                            [
                                -121.975125,
                                37.376267
                            ],
                            [
                                -121.975124,
                                37.37627
                            ],
                            [
                                -121.975124,
                                37.376278
                            ],
                            [
                                -121.975123,
                                37.376293
                            ],
                            [
                                -121.975124,
                                37.376309
                            ],
                            [
                                -121.975126,
                                37.376325
                            ],
                            [
                                -121.97513,
                                37.376341
                            ],
                            [
                                -121.975134,
                                37.376357
                            ],
                            [
                                -121.975143,
                                37.376381
                            ],
                            [
                                -121.975157,
                                37.376415
                            ],
                            [
                                -121.975175,
                                37.376449
                            ],
                            [
                                -121.975205,
                                37.376502
                            ],
                            [
                                -121.97525,
                                37.376575
                            ],
                            [
                                -121.975285,
                                37.376632
                            ],
                            [
                                -121.975307,
                                37.37667
                            ],
                            [
                                -121.975327,
                                37.37671
                            ],
                            [
                                -121.975345,
                                37.37675
                            ],
                            [
                                -121.975357,
                                37.376781
                            ],
                            [
                                -121.975364,
                                37.376801
                            ],
                            [
                                -121.97537,
                                37.376822
                            ],
                            [
                                -121.975375,
                                37.376843
                            ],
                            [
                                -121.975377,
                                37.376854
                            ],
                            [
                                -121.975385,
                                37.376894
                            ],
                            [
                                -121.9754,
                                37.376971
                            ],
                            [
                                -121.97541,
                                37.377026
                            ],
                            [
                                -121.975415,
                                37.377062
                            ],
                            [
                                -121.975418,
                                37.377099
                            ],
                            [
                                -121.97542,
                                37.377137
                            ],
                            [
                                -121.975419,
                                37.377176
                            ],
                            [
                                -121.975415,
                                37.377216
                            ],
                            [
                                -121.975409,
                                37.377258
                            ],
                            [
                                -121.975399,
                                37.377303
                            ],
                            [
                                -121.975386,
                                37.377351
                            ],
                            [
                                -121.975368,
                                37.377403
                            ],
                            [
                                -121.975347,
                                37.377458
                            ],
                            [
                                -121.97532,
                                37.377517
                            ],
                            [
                                -121.975305,
                                37.377548
                            ],
                            [
                                -121.975305,
                                37.377548
                            ]
                        ]
                    ],
                    "type": "Polygon"
                }
            }
        }
    },
    {
        "envelope": {
            "instance": {
                "id": 2,
                "name": "Blackwater Pasture",
                "type": "pasture",
                "farm": 2,
                "geometry": {
                    "coordinates": [
                        [
                            [
                                -121.975423,
                                37.375048
                            ],
                            [
                                -121.972902,
                                37.375048
                            ],
                            [
                                -121.972902,
                                37.375849
                            ],
                            [
                                -121.97291,
                                37.375861
                            ],
                            [
                                -121.972923,
                                37.375879
                            ],
                            [
                                -121.972933,
                                37.375891
                            ],
                            [
                                -121.972944,
                                37.375903
                            ],
                            [
                                -121.972956,
                                37.375915
                            ],
                            [
                                -121.97297,
                                37.375926
                            ],
                            [
                                -121.972984,
                                37.375937
                            ],
                            [
                                -121.973,
                                37.375947
                            ],
                            [
                                -121.973016,
                                37.375957
                            ],
                            [
                                -121.973035,
                                37.375966
                            ],
                            [
                                -121.973054,
                                37.375974
                            ],
                            [
                                -121.973075,
                                37.375981
                            ],
                            [
                                -121.973097,
                                37.375987
                            ],
                            [
                                -121.973121,
                                37.375992
                            ],
                            [
                                -121.973146,
                                37.375996
                            ],
                            [
                                -121.97316,
                                37.375997
                            ],
                            [
                                -121.973173,
                                37.375998
                            ],
                            [
                                -121.973199,
                                37.375999
                            ],
                            [
                                -121.973225,
                                37.375999
                            ],
                            [
                                -121.973252,
                                37.375998
                            ],
                            [
                                -121.97328,
                                37.375996
                            ],
                            [
                                -121.973308,
                                37.375992
                            ],
                            [
                                -121.973337,
                                37.375987
                            ],
                            [
                                -121.973365,
                                37.375982
                            ],
                            [
                                -121.973395,
                                37.375975
                            ],
                            [
                                -121.973425,
                                37.375968
                            ],
                            [
                                -121.973471,
                                37.375955
                            ],
                            [
                                -121.973533,
                                37.375934
                            ],
                            [
                                -121.973598,
                                37.375911
                            ],
                            [
                                -121.973665,
                                37.375886
                            ],
                            [
                                -121.973734,
                                37.375858
                            ],
                            [
                                -121.973841,
                                37.375813
                            ],
                            [
                                -121.973991,
                                37.375749
                            ],
                            [
                                -121.974109,
                                37.375699
                            ],
                            [
                                -121.974191,
                                37.375666
                            ],
                            [
                                -121.974233,
                                37.375649
                            ],
                            [
                                -121.974332,
                                37.37561
                            ],
                            [
                                -121.974528,
                                37.375533
                            ],
                            [
                                -121.974677,
                                37.375476
                            ],
                            [
                                -121.974792,
                                37.375434
                            ],
                            [
                                -121.974869,
                                37.375407
                            ],
                            [
                                -121.974944,
                                37.375382
                            ],
                            [
                                -121.975016,
                                37.375358
                            ],
                            [
                                -121.975085,
                                37.375338
                            ],
                            [
                                -121.975149,
                                37.375321
                            ],
                            [
                                -121.975194,
                                37.37531
                            ],
                            [
                                -121.975221,
                                37.375305
                            ],
                            [
                                -121.975247,
                                37.3753
                            ],
                            [
                                -121.975271,
                                37.375297
                            ],
                            [
                                -121.975282,
                                37.375295
                            ],
                            [
                                -121.975288,
                                37.375295
                            ],
                            [
                                -121.9753,
                                37.375293
                            ],
                            [
                                -121.975311,
                                37.37529
                            ],
                            [
                                -121.975322,
                                37.375286
                            ],
                            [
                                -121.975332,
                                37.375282
                            ],
                            [
                                -121.975341,
                                37.375277
                            ],
                            [
                                -121.97535,
                                37.375271
                            ],
                            [
                                -121.975357,
                                37.375265
                            ],
                            [
                                -121.975368,
                                37.375255
                            ],
                            [
                                -121.975381,
                                37.37524
                            ],
                            [
                                -121.975392,
                                37.375223
                            ],
                            [
                                -121.9754,
                                37.375205
                            ],
                            [
                                -121.975407,
                                37.375186
                            ],
                            [
                                -121.975413,
                                37.375166
                            ],
                            [
                                -121.975417,
                                37.375147
                            ],
                            [
                                -121.97542,
                                37.375127
                            ],
                            [
                                -121.975423,
                                37.375098
                            ],
                            [
                                -121.975423,
                                37.375063
                            ],
                            [
                                -121.975423,
                                37.375048
                            ],
                            [
                                -121.975423,
                                37.375048
                            ]
                        ]
                    ],
                    "type": "Polygon"
                }
            }
        }
    },
    {
        "envelope": {
            "instance": {
                "id": 3,
                "name": "Valley Pasture",
                "type": "pasture",
                "farm": 3,
                "geometry": {
                    "coordinates": [
                        [
                            [
                                -121.977579,
                                37.375657
                            ],
                            [
                                -121.977579,
                                37.375048
                            ],
                            [
                                -121.975878,
                                37.375048
                            ],
                            [
                                -121.975888,
                                37.37507
                            ],
                            [
                                -121.975907,
                                37.375108
                            ],
                            [
                                -121.975923,
                                37.375135
                            ],
                            [
                                -121.975939,
                                37.375162
                            ],
                            [
                                -121.975957,
                                37.375187
                            ],
                            [
                                -121.975971,
                                37.375205
                            ],
                            [
                                -121.975981,
                                37.375216
                            ],
                            [
                                -121.975991,
                                37.375225
                            ],
                            [
                                -121.976001,
                                37.375234
                            ],
                            [
                                -121.976006,
                                37.375238
                            ],
                            [
                                -121.97601,
                                37.37524
                            ],
                            [
                                -121.976018,
                                37.375245
                            ],
                            [
                                -121.976027,
                                37.375249
                            ],
                            [
                                -121.976037,
                                37.375252
                            ],
                            [
                                -121.976053,
                                37.375255
                            ],
                            [
                                -121.976076,
                                37.375258
                            ],
                            [
                                -121.976101,
                                37.375259
                            ],
                            [
                                -121.976128,
                                37.375259
                            ],
                            [
                                -121.976172,
                                37.375257
                            ],
                            [
                                -121.976236,
                                37.375253
                            ],
                            [
                                -121.976286,
                                37.375252
                            ],
                            [
                                -121.976321,
                                37.375253
                            ],
                            [
                                -121.976355,
                                37.375255
                            ],
                            [
                                -121.97639,
                                37.375259
                            ],
                            [
                                -121.976417,
                                37.375264
                            ],
                            [
                                -121.976434,
                                37.375268
                            ],
                            [
                                -121.976451,
                                37.375272
                            ],
                            [
                                -121.976469,
                                37.375278
                            ],
                            [
                                -121.976477,
                                37.375281
                            ],
                            [
                                -121.976486,
                                37.375285
                            ],
                            [
                                -121.976503,
                                37.375292
                            ],
                            [
                                -121.97653,
                                37.375305
                            ],
                            [
                                -121.976566,
                                37.375324
                            ],
                            [
                                -121.976603,
                                37.375346
                            ],
                            [
                                -121.976642,
                                37.375371
                            ],
                            [
                                -121.97668,
                                37.375397
                            ],
                            [
                                -121.976739,
                                37.375437
                            ],
                            [
                                -121.976819,
                                37.375493
                            ],
                            [
                                -121.976879,
                                37.375533
                            ],
                            [
                                -121.976919,
                                37.375558
                            ],
                            [
                                -121.976958,
                                37.375581
                            ],
                            [
                                -121.976997,
                                37.375601
                            ],
                            [
                                -121.977026,
                                37.375615
                            ],
                            [
                                -121.977045,
                                37.375623
                            ],
                            [
                                -121.977064,
                                37.37563
                            ],
                            [
                                -121.977082,
                                37.375636
                            ],
                            [
                                -121.977092,
                                37.375639
                            ],
                            [
                                -121.977107,
                                37.375643
                            ],
                            [
                                -121.97714,
                                37.375651
                            ],
                            [
                                -121.977174,
                                37.375656
                            ],
                            [
                                -121.977208,
                                37.375661
                            ],
                            [
                                -121.977244,
                                37.375664
                            ],
                            [
                                -121.97728,
                                37.375667
                            ],
                            [
                                -121.977315,
                                37.375668
                            ],
                            [
                                -121.97735,
                                37.375669
                            ],
                            [
                                -121.977401,
                                37.375668
                            ],
                            [
                                -121.977464,
                                37.375666
                            ],
                            [
                                -121.977519,
                                37.375662
                            ],
                            [
                                -121.977563,
                                37.375659
                            ],
                            [
                                -121.977579,
                                37.375657
                            ],
                            [
                                -121.977579,
                                37.375657
                            ]
                        ]
                    ],
                    "type": "Polygon"
                }
            }
        }
    },
    {
        "envelope": {
            "instance": {
                "id": 4,
                "name": "Northern Fields",
                "type": "pasture",
                "farm": 3,
                "geometry": {
                    "coordinates": [
                        [
                            [
                                -121.972902,
                                37.376415
                            ],
                            [
                                -121.972902,
                                37.377548
                            ],
                            [
                                -121.974586,
                                37.377548
                            ],
                            [
                                -121.974598,
                                37.377519
                            ],
                            [
                                -121.974628,
                                37.377445
                            ],
                            [
                                -121.974652,
                                37.377378
                            ],
                            [
                                -121.974669,
                                37.377329
                            ],
                            [
                                -121.974684,
                                37.377278
                            ],
                            [
                                -121.974698,
                                37.377226
                            ],
                            [
                                -121.97471,
                                37.377174
                            ],
                            [
                                -121.97472,
                                37.377121
                            ],
                            [
                                -121.974725,
                                37.377082
                            ],
                            [
                                -121.974728,
                                37.377056
                            ],
                            [
                                -121.974729,
                                37.377031
                            ],
                            [
                                -121.97473,
                                37.377007
                            ],
                            [
                                -121.974729,
                                37.376983
                            ],
                            [
                                -121.974727,
                                37.37696
                            ],
                            [
                                -121.974724,
                                37.376938
                            ],
                            [
                                -121.97472,
                                37.376917
                            ],
                            [
                                -121.974714,
                                37.376897
                            ],
                            [
                                -121.974707,
                                37.376878
                            ],
                            [
                                -121.974698,
                                37.37686
                            ],
                            [
                                -121.974688,
                                37.376844
                            ],
                            [
                                -121.974682,
                                37.376836
                            ],
                            [
                                -121.974674,
                                37.376827
                            ],
                            [
                                -121.974659,
                                37.376811
                            ],
                            [
                                -121.974643,
                                37.376796
                            ],
                            [
                                -121.974627,
                                37.376783
                            ],
                            [
                                -121.97461,
                                37.376771
                            ],
                            [
                                -121.974592,
                                37.376761
                            ],
                            [
                                -121.974573,
                                37.376752
                            ],
                            [
                                -121.974555,
                                37.376744
                            ],
                            [
                                -121.974535,
                                37.376737
                            ],
                            [
                                -121.974516,
                                37.376731
                            ],
                            [
                                -121.974496,
                                37.376726
                            ],
                            [
                                -121.974475,
                                37.376721
                            ],
                            [
                                -121.974444,
                                37.376716
                            ],
                            [
                                -121.974402,
                                37.376711
                            ],
                            [
                                -121.974337,
                                37.376706
                            ],
                            [
                                -121.974273,
                                37.376701
                            ],
                            [
                                -121.97423,
                                37.376697
                            ],
                            [
                                -121.974188,
                                37.376692
                            ],
                            [
                                -121.974158,
                                37.376686
                            ],
                            [
                                -121.974137,
                                37.376682
                            ],
                            [
                                -121.974118,
                                37.376676
                            ],
                            [
                                -121.974098,
                                37.37667
                            ],
                            [
                                -121.97408,
                                37.376663
                            ],
                            [
                                -121.974061,
                                37.376654
                            ],
                            [
                                -121.974052,
                                37.37665
                            ],
                            [
                                -121.974044,
                                37.376645
                            ],
                            [
                                -121.974029,
                                37.376634
                            ],
                            [
                                -121.974017,
                                37.376623
                            ],
                            [
                                -121.974007,
                                37.376612
                            ],
                            [
                                -121.973999,
                                37.3766
                            ],
                            [
                                -121.973994,
                                37.376587
                            ],
                            [
                                -121.97399,
                                37.376574
                            ],
                            [
                                -121.973987,
                                37.376561
                            ],
                            [
                                -121.973985,
                                37.37654
                            ],
                            [
                                -121.973986,
                                37.376512
                            ],
                            [
                                -121.973987,
                                37.376483
                            ],
                            [
                                -121.973987,
                                37.376455
                            ],
                            [
                                -121.973986,
                                37.376434
                            ],
                            [
                                -121.973984,
                                37.376421
                            ],
                            [
                                -121.97398,
                                37.376407
                            ],
                            [
                                -121.973974,
                                37.376395
                            ],
                            [
                                -121.973967,
                                37.376382
                            ],
                            [
                                -121.973958,
                                37.37637
                            ],
                            [
                                -121.973946,
                                37.376359
                            ],
                            [
                                -121.973931,
                                37.376348
                            ],
                            [
                                -121.973914,
                                37.376338
                            ],
                            [
                                -121.973893,
                                37.376329
                            ],
                            [
                                -121.973869,
                                37.37632
                            ],
                            [
                                -121.973842,
                                37.376313
                            ],
                            [
                                -121.97381,
                                37.376306
                            ],
                            [
                                -121.973774,
                                37.3763
                            ],
                            [
                                -121.973734,
                                37.376296
                            ],
                            [
                                -121.973689,
                                37.376292
                            ],
                            [
                                -121.973665,
                                37.376291
                            ],
                            [
                                -121.973629,
                                37.37629
                            ],
                            [
                                -121.97356,
                                37.376289
                            ],
                            [
                                -121.973494,
                                37.37629
                            ],
                            [
                                -121.97343,
                                37.376293
                            ],
                            [
                                -121.97337,
                                37.376298
                            ],
                            [
                                -121.973312,
                                37.376305
                            ],
                            [
                                -121.973258,
                                37.376313
                            ],
                            [
                                -121.973207,
                                37.376322
                            ],
                            [
                                -121.973159,
                                37.376332
                            ],
                            [
                                -121.973114,
                                37.376343
                            ],
                            [
                                -121.973073,
                                37.376354
                            ],
                            [
                                -121.973034,
                                37.376366
                            ],
                            [
                                -121.972999,
                                37.376377
                            ],
                            [
                                -121.972967,
                                37.376389
                            ],
                            [
                                -121.972926,
                                37.376405
                            ],
                            [
                                -121.972902,
                                37.376415
                            ],
                            [
                                -121.972902,
                                37.376415
                            ]
                        ]
                    ],
                    "type": "Polygon"
                }
            }
        }
    }
]'))

return
    for $doc in $data/*
    return xdmp:invoke-function(
        function() {
            xdmp:document-insert(
                "/llamaverse/pasture/" || sem:uuid-string() || ".json",
                $doc,
                <options xmlns="xdmp:document-insert">  
                    <permissions>{xdmp:default-permissions()}</permissions>
                    <collections>{
                      <collection>/type/pasture</collection>,
                      for $coll in xdmp:default-collections()
                      return <collection>{$coll}</collection>
                    }</collections>
                </options>
            )
        },
        map:entry("userId", xdmp:user("mother"))
            => map:with("update", "true")
            => map:with("isolation", "different-transaction") 
    )
'use strict';

const data = [
    {
        "envelope": {
            "instance": {
                "id": 1,
                "name": "High Hill Field",
                "type": "pasture",
                "farm": 1,
                "geometry": {
                    "coordinates": [
                        [
                            [
                                -121.975305,
                                37.377548
                            ],
                            [
                                -121.976849,
                                37.377548
                            ],
                            [
                                -121.976869,
                                37.377513
                            ],
                            [
                                -121.976919,
                                37.37743
                            ],
                            [
                                -121.976962,
                                37.37736
                            ],
                            [
                                -121.977011,
                                37.377287
                            ],
                            [
                                -121.977049,
                                37.377232
                            ],
                            [
                                -121.977075,
                                37.377197
                            ],
                            [
                                -121.977101,
                                37.377163
                            ],
                            [
                                -121.977126,
                                37.377133
                            ],
                            [
                                -121.977151,
                                37.377105
                            ],
                            [
                                -121.977174,
                                37.377081
                            ],
                            [
                                -121.977186,
                                37.377071
                            ],
                            [
                                -121.977195,
                                37.377063
                            ],
                            [
                                -121.977217,
                                37.377047
                            ],
                            [
                                -121.97724,
                                37.377032
                            ],
                            [
                                -121.977264,
                                37.377016
                            ],
                            [
                                -121.97729,
                                37.377001
                            ],
                            [
                                -121.977317,
                                37.376987
                            ],
                            [
                                -121.977358,
                                37.376966
                            ],
                            [
                                -121.977414,
                                37.376941
                            ],
                            [
                                -121.977468,
                                37.376918
                            ],
                            [
                                -121.977518,
                                37.376899
                            ],
                            [
                                -121.977561,
                                37.376883
                            ],
                            [
                                -121.977579,
                                37.376876
                            ],
                            [
                                -121.977579,
                                37.376176
                            ],
                            [
                                -121.977534,
                                37.376159
                            ],
                            [
                                -121.977391,
                                37.376106
                            ],
                            [
                                -121.977261,
                                37.376059
                            ],
                            [
                                -121.977174,
                                37.376029
                            ],
                            [
                                -121.977095,
                                37.376003
                            ],
                            [
                                -121.977045,
                                37.375988
                            ],
                            [
                                -121.977017,
                                37.37598
                            ],
                            [
                                -121.977005,
                                37.375977
                            ],
                            [
                                -121.97698,
                                37.375972
                            ],
                            [
                                -121.976934,
                                37.375963
                            ],
                            [
                                -121.976893,
                                37.375958
                            ],
                            [
                                -121.976859,
                                37.375955
                            ],
                            [
                                -121.976831,
                                37.375953
                            ],
                            [
                                -121.97681,
                                37.375953
                            ],
                            [
                                -121.976791,
                                37.375953
                            ],
                            [
                                -121.976787,
                                37.375954
                            ],
                            [
                                -121.976756,
                                37.375956
                            ],
                            [
                                -121.976677,
                                37.375962
                            ],
                            [
                                -121.976578,
                                37.375971
                            ],
                            [
                                -121.976464,
                                37.375982
                            ],
                            [
                                -121.976338,
                                37.375996
                            ],
                            [
                                -121.976203,
                                37.376012
                            ],
                            [
                                -121.976063,
                                37.376031
                            ],
                            [
                                -121.975921,
                                37.376051
                            ],
                            [
                                -121.97578,
                                37.376073
                            ],
                            [
                                -121.975678,
                                37.37609
                            ],
                            [
                                -121.975612,
                                37.376102
                            ],
                            [
                                -121.975548,
                                37.376114
                            ],
                            [
                                -121.975487,
                                37.376127
                            ],
                            [
                                -121.97543,
                                37.37614
                            ],
                            [
                                -121.975376,
                                37.376153
                            ],
                            [
                                -121.975326,
                                37.376166
                            ],
                            [
                                -121.97528,
                                37.376179
                            ],
                            [
                                -121.97524,
                                37.376193
                            ],
                            [
                                -121.975205,
                                37.376207
                            ],
                            [
                                -121.975182,
                                37.376217
                            ],
                            [
                                -121.975169,
                                37.376224
                            ],
                            [
                                -121.975157,
                                37.376231
                            ],
                            [
                                -121.975147,
                                37.376238
                            ],
                            [
                                -121.975139,
                                37.376245
                            ],
                            [
                                -121.975133,
                                37.376252
                            ],
                            [
                                -121.975128,
                                37.37626
                            ],
                            [
                                -121.975125,
                                37.376267
                            ],
                            [
                                -121.975124,
                                37.37627
                            ],
                            [
                                -121.975124,
                                37.376278
                            ],
                            [
                                -121.975123,
                                37.376293
                            ],
                            [
                                -121.975124,
                                37.376309
                            ],
                            [
                                -121.975126,
                                37.376325
                            ],
                            [
                                -121.97513,
                                37.376341
                            ],
                            [
                                -121.975134,
                                37.376357
                            ],
                            [
                                -121.975143,
                                37.376381
                            ],
                            [
                                -121.975157,
                                37.376415
                            ],
                            [
                                -121.975175,
                                37.376449
                            ],
                            [
                                -121.975205,
                                37.376502
                            ],
                            [
                                -121.97525,
                                37.376575
                            ],
                            [
                                -121.975285,
                                37.376632
                            ],
                            [
                                -121.975307,
                                37.37667
                            ],
                            [
                                -121.975327,
                                37.37671
                            ],
                            [
                                -121.975345,
                                37.37675
                            ],
                            [
                                -121.975357,
                                37.376781
                            ],
                            [
                                -121.975364,
                                37.376801
                            ],
                            [
                                -121.97537,
                                37.376822
                            ],
                            [
                                -121.975375,
                                37.376843
                            ],
                            [
                                -121.975377,
                                37.376854
                            ],
                            [
                                -121.975385,
                                37.376894
                            ],
                            [
                                -121.9754,
                                37.376971
                            ],
                            [
                                -121.97541,
                                37.377026
                            ],
                            [
                                -121.975415,
                                37.377062
                            ],
                            [
                                -121.975418,
                                37.377099
                            ],
                            [
                                -121.97542,
                                37.377137
                            ],
                            [
                                -121.975419,
                                37.377176
                            ],
                            [
                                -121.975415,
                                37.377216
                            ],
                            [
                                -121.975409,
                                37.377258
                            ],
                            [
                                -121.975399,
                                37.377303
                            ],
                            [
                                -121.975386,
                                37.377351
                            ],
                            [
                                -121.975368,
                                37.377403
                            ],
                            [
                                -121.975347,
                                37.377458
                            ],
                            [
                                -121.97532,
                                37.377517
                            ],
                            [
                                -121.975305,
                                37.377548
                            ],
                            [
                                -121.975305,
                                37.377548
                            ]
                        ]
                    ],
                    "type": "Polygon"
                }
            }
        }
    },
    {
        "envelope": {
            "instance": {
                "id": 2,
                "name": "Blackwater Pasture",
                "type": "pasture",
                "farm": 2,
                "geometry": {
                    "coordinates": [
                        [
                            [
                                -121.975423,
                                37.375048
                            ],
                            [
                                -121.972902,
                                37.375048
                            ],
                            [
                                -121.972902,
                                37.375849
                            ],
                            [
                                -121.97291,
                                37.375861
                            ],
                            [
                                -121.972923,
                                37.375879
                            ],
                            [
                                -121.972933,
                                37.375891
                            ],
                            [
                                -121.972944,
                                37.375903
                            ],
                            [
                                -121.972956,
                                37.375915
                            ],
                            [
                                -121.97297,
                                37.375926
                            ],
                            [
                                -121.972984,
                                37.375937
                            ],
                            [
                                -121.973,
                                37.375947
                            ],
                            [
                                -121.973016,
                                37.375957
                            ],
                            [
                                -121.973035,
                                37.375966
                            ],
                            [
                                -121.973054,
                                37.375974
                            ],
                            [
                                -121.973075,
                                37.375981
                            ],
                            [
                                -121.973097,
                                37.375987
                            ],
                            [
                                -121.973121,
                                37.375992
                            ],
                            [
                                -121.973146,
                                37.375996
                            ],
                            [
                                -121.97316,
                                37.375997
                            ],
                            [
                                -121.973173,
                                37.375998
                            ],
                            [
                                -121.973199,
                                37.375999
                            ],
                            [
                                -121.973225,
                                37.375999
                            ],
                            [
                                -121.973252,
                                37.375998
                            ],
                            [
                                -121.97328,
                                37.375996
                            ],
                            [
                                -121.973308,
                                37.375992
                            ],
                            [
                                -121.973337,
                                37.375987
                            ],
                            [
                                -121.973365,
                                37.375982
                            ],
                            [
                                -121.973395,
                                37.375975
                            ],
                            [
                                -121.973425,
                                37.375968
                            ],
                            [
                                -121.973471,
                                37.375955
                            ],
                            [
                                -121.973533,
                                37.375934
                            ],
                            [
                                -121.973598,
                                37.375911
                            ],
                            [
                                -121.973665,
                                37.375886
                            ],
                            [
                                -121.973734,
                                37.375858
                            ],
                            [
                                -121.973841,
                                37.375813
                            ],
                            [
                                -121.973991,
                                37.375749
                            ],
                            [
                                -121.974109,
                                37.375699
                            ],
                            [
                                -121.974191,
                                37.375666
                            ],
                            [
                                -121.974233,
                                37.375649
                            ],
                            [
                                -121.974332,
                                37.37561
                            ],
                            [
                                -121.974528,
                                37.375533
                            ],
                            [
                                -121.974677,
                                37.375476
                            ],
                            [
                                -121.974792,
                                37.375434
                            ],
                            [
                                -121.974869,
                                37.375407
                            ],
                            [
                                -121.974944,
                                37.375382
                            ],
                            [
                                -121.975016,
                                37.375358
                            ],
                            [
                                -121.975085,
                                37.375338
                            ],
                            [
                                -121.975149,
                                37.375321
                            ],
                            [
                                -121.975194,
                                37.37531
                            ],
                            [
                                -121.975221,
                                37.375305
                            ],
                            [
                                -121.975247,
                                37.3753
                            ],
                            [
                                -121.975271,
                                37.375297
                            ],
                            [
                                -121.975282,
                                37.375295
                            ],
                            [
                                -121.975288,
                                37.375295
                            ],
                            [
                                -121.9753,
                                37.375293
                            ],
                            [
                                -121.975311,
                                37.37529
                            ],
                            [
                                -121.975322,
                                37.375286
                            ],
                            [
                                -121.975332,
                                37.375282
                            ],
                            [
                                -121.975341,
                                37.375277
                            ],
                            [
                                -121.97535,
                                37.375271
                            ],
                            [
                                -121.975357,
                                37.375265
                            ],
                            [
                                -121.975368,
                                37.375255
                            ],
                            [
                                -121.975381,
                                37.37524
                            ],
                            [
                                -121.975392,
                                37.375223
                            ],
                            [
                                -121.9754,
                                37.375205
                            ],
                            [
                                -121.975407,
                                37.375186
                            ],
                            [
                                -121.975413,
                                37.375166
                            ],
                            [
                                -121.975417,
                                37.375147
                            ],
                            [
                                -121.97542,
                                37.375127
                            ],
                            [
                                -121.975423,
                                37.375098
                            ],
                            [
                                -121.975423,
                                37.375063
                            ],
                            [
                                -121.975423,
                                37.375048
                            ],
                            [
                                -121.975423,
                                37.375048
                            ]
                        ]
                    ],
                    "type": "Polygon"
                }
            }
        }
    },
    {
        "envelope": {
            "instance": {
                "id": 3,
                "name": "Valley Pasture",
                "type": "pasture",
                "farm": 3,
                "geometry": {
                    "coordinates": [
                        [
                            [
                                -121.977579,
                                37.375657
                            ],
                            [
                                -121.977579,
                                37.375048
                            ],
                            [
                                -121.975878,
                                37.375048
                            ],
                            [
                                -121.975888,
                                37.37507
                            ],
                            [
                                -121.975907,
                                37.375108
                            ],
                            [
                                -121.975923,
                                37.375135
                            ],
                            [
                                -121.975939,
                                37.375162
                            ],
                            [
                                -121.975957,
                                37.375187
                            ],
                            [
                                -121.975971,
                                37.375205
                            ],
                            [
                                -121.975981,
                                37.375216
                            ],
                            [
                                -121.975991,
                                37.375225
                            ],
                            [
                                -121.976001,
                                37.375234
                            ],
                            [
                                -121.976006,
                                37.375238
                            ],
                            [
                                -121.97601,
                                37.37524
                            ],
                            [
                                -121.976018,
                                37.375245
                            ],
                            [
                                -121.976027,
                                37.375249
                            ],
                            [
                                -121.976037,
                                37.375252
                            ],
                            [
                                -121.976053,
                                37.375255
                            ],
                            [
                                -121.976076,
                                37.375258
                            ],
                            [
                                -121.976101,
                                37.375259
                            ],
                            [
                                -121.976128,
                                37.375259
                            ],
                            [
                                -121.976172,
                                37.375257
                            ],
                            [
                                -121.976236,
                                37.375253
                            ],
                            [
                                -121.976286,
                                37.375252
                            ],
                            [
                                -121.976321,
                                37.375253
                            ],
                            [
                                -121.976355,
                                37.375255
                            ],
                            [
                                -121.97639,
                                37.375259
                            ],
                            [
                                -121.976417,
                                37.375264
                            ],
                            [
                                -121.976434,
                                37.375268
                            ],
                            [
                                -121.976451,
                                37.375272
                            ],
                            [
                                -121.976469,
                                37.375278
                            ],
                            [
                                -121.976477,
                                37.375281
                            ],
                            [
                                -121.976486,
                                37.375285
                            ],
                            [
                                -121.976503,
                                37.375292
                            ],
                            [
                                -121.97653,
                                37.375305
                            ],
                            [
                                -121.976566,
                                37.375324
                            ],
                            [
                                -121.976603,
                                37.375346
                            ],
                            [
                                -121.976642,
                                37.375371
                            ],
                            [
                                -121.97668,
                                37.375397
                            ],
                            [
                                -121.976739,
                                37.375437
                            ],
                            [
                                -121.976819,
                                37.375493
                            ],
                            [
                                -121.976879,
                                37.375533
                            ],
                            [
                                -121.976919,
                                37.375558
                            ],
                            [
                                -121.976958,
                                37.375581
                            ],
                            [
                                -121.976997,
                                37.375601
                            ],
                            [
                                -121.977026,
                                37.375615
                            ],
                            [
                                -121.977045,
                                37.375623
                            ],
                            [
                                -121.977064,
                                37.37563
                            ],
                            [
                                -121.977082,
                                37.375636
                            ],
                            [
                                -121.977092,
                                37.375639
                            ],
                            [
                                -121.977107,
                                37.375643
                            ],
                            [
                                -121.97714,
                                37.375651
                            ],
                            [
                                -121.977174,
                                37.375656
                            ],
                            [
                                -121.977208,
                                37.375661
                            ],
                            [
                                -121.977244,
                                37.375664
                            ],
                            [
                                -121.97728,
                                37.375667
                            ],
                            [
                                -121.977315,
                                37.375668
                            ],
                            [
                                -121.97735,
                                37.375669
                            ],
                            [
                                -121.977401,
                                37.375668
                            ],
                            [
                                -121.977464,
                                37.375666
                            ],
                            [
                                -121.977519,
                                37.375662
                            ],
                            [
                                -121.977563,
                                37.375659
                            ],
                            [
                                -121.977579,
                                37.375657
                            ],
                            [
                                -121.977579,
                                37.375657
                            ]
                        ]
                    ],
                    "type": "Polygon"
                }
            }
        }
    },
    {
        "envelope": {
            "instance": {
                "id": 4,
                "name": "Northern Fields",
                "type": "pasture",
                "farm": 3,
                "geometry": {
                    "coordinates": [
                        [
                            [
                                -121.972902,
                                37.376415
                            ],
                            [
                                -121.972902,
                                37.377548
                            ],
                            [
                                -121.974586,
                                37.377548
                            ],
                            [
                                -121.974598,
                                37.377519
                            ],
                            [
                                -121.974628,
                                37.377445
                            ],
                            [
                                -121.974652,
                                37.377378
                            ],
                            [
                                -121.974669,
                                37.377329
                            ],
                            [
                                -121.974684,
                                37.377278
                            ],
                            [
                                -121.974698,
                                37.377226
                            ],
                            [
                                -121.97471,
                                37.377174
                            ],
                            [
                                -121.97472,
                                37.377121
                            ],
                            [
                                -121.974725,
                                37.377082
                            ],
                            [
                                -121.974728,
                                37.377056
                            ],
                            [
                                -121.974729,
                                37.377031
                            ],
                            [
                                -121.97473,
                                37.377007
                            ],
                            [
                                -121.974729,
                                37.376983
                            ],
                            [
                                -121.974727,
                                37.37696
                            ],
                            [
                                -121.974724,
                                37.376938
                            ],
                            [
                                -121.97472,
                                37.376917
                            ],
                            [
                                -121.974714,
                                37.376897
                            ],
                            [
                                -121.974707,
                                37.376878
                            ],
                            [
                                -121.974698,
                                37.37686
                            ],
                            [
                                -121.974688,
                                37.376844
                            ],
                            [
                                -121.974682,
                                37.376836
                            ],
                            [
                                -121.974674,
                                37.376827
                            ],
                            [
                                -121.974659,
                                37.376811
                            ],
                            [
                                -121.974643,
                                37.376796
                            ],
                            [
                                -121.974627,
                                37.376783
                            ],
                            [
                                -121.97461,
                                37.376771
                            ],
                            [
                                -121.974592,
                                37.376761
                            ],
                            [
                                -121.974573,
                                37.376752
                            ],
                            [
                                -121.974555,
                                37.376744
                            ],
                            [
                                -121.974535,
                                37.376737
                            ],
                            [
                                -121.974516,
                                37.376731
                            ],
                            [
                                -121.974496,
                                37.376726
                            ],
                            [
                                -121.974475,
                                37.376721
                            ],
                            [
                                -121.974444,
                                37.376716
                            ],
                            [
                                -121.974402,
                                37.376711
                            ],
                            [
                                -121.974337,
                                37.376706
                            ],
                            [
                                -121.974273,
                                37.376701
                            ],
                            [
                                -121.97423,
                                37.376697
                            ],
                            [
                                -121.974188,
                                37.376692
                            ],
                            [
                                -121.974158,
                                37.376686
                            ],
                            [
                                -121.974137,
                                37.376682
                            ],
                            [
                                -121.974118,
                                37.376676
                            ],
                            [
                                -121.974098,
                                37.37667
                            ],
                            [
                                -121.97408,
                                37.376663
                            ],
                            [
                                -121.974061,
                                37.376654
                            ],
                            [
                                -121.974052,
                                37.37665
                            ],
                            [
                                -121.974044,
                                37.376645
                            ],
                            [
                                -121.974029,
                                37.376634
                            ],
                            [
                                -121.974017,
                                37.376623
                            ],
                            [
                                -121.974007,
                                37.376612
                            ],
                            [
                                -121.973999,
                                37.3766
                            ],
                            [
                                -121.973994,
                                37.376587
                            ],
                            [
                                -121.97399,
                                37.376574
                            ],
                            [
                                -121.973987,
                                37.376561
                            ],
                            [
                                -121.973985,
                                37.37654
                            ],
                            [
                                -121.973986,
                                37.376512
                            ],
                            [
                                -121.973987,
                                37.376483
                            ],
                            [
                                -121.973987,
                                37.376455
                            ],
                            [
                                -121.973986,
                                37.376434
                            ],
                            [
                                -121.973984,
                                37.376421
                            ],
                            [
                                -121.97398,
                                37.376407
                            ],
                            [
                                -121.973974,
                                37.376395
                            ],
                            [
                                -121.973967,
                                37.376382
                            ],
                            [
                                -121.973958,
                                37.37637
                            ],
                            [
                                -121.973946,
                                37.376359
                            ],
                            [
                                -121.973931,
                                37.376348
                            ],
                            [
                                -121.973914,
                                37.376338
                            ],
                            [
                                -121.973893,
                                37.376329
                            ],
                            [
                                -121.973869,
                                37.37632
                            ],
                            [
                                -121.973842,
                                37.376313
                            ],
                            [
                                -121.97381,
                                37.376306
                            ],
                            [
                                -121.973774,
                                37.3763
                            ],
                            [
                                -121.973734,
                                37.376296
                            ],
                            [
                                -121.973689,
                                37.376292
                            ],
                            [
                                -121.973665,
                                37.376291
                            ],
                            [
                                -121.973629,
                                37.37629
                            ],
                            [
                                -121.97356,
                                37.376289
                            ],
                            [
                                -121.973494,
                                37.37629
                            ],
                            [
                                -121.97343,
                                37.376293
                            ],
                            [
                                -121.97337,
                                37.376298
                            ],
                            [
                                -121.973312,
                                37.376305
                            ],
                            [
                                -121.973258,
                                37.376313
                            ],
                            [
                                -121.973207,
                                37.376322
                            ],
                            [
                                -121.973159,
                                37.376332
                            ],
                            [
                                -121.973114,
                                37.376343
                            ],
                            [
                                -121.973073,
                                37.376354
                            ],
                            [
                                -121.973034,
                                37.376366
                            ],
                            [
                                -121.972999,
                                37.376377
                            ],
                            [
                                -121.972967,
                                37.376389
                            ],
                            [
                                -121.972926,
                                37.376405
                            ],
                            [
                                -121.972902,
                                37.376415
                            ],
                            [
                                -121.972902,
                                37.376415
                            ]
                        ]
                    ],
                    "type": "Polygon"
                }
            }
        }
    }
];

data.forEach((doc) => {
    xdmp.invokeFunction(
        () => {
            xdmp.documentInsert(
                `/llamaverse/pasture/${sem.uuidString()}.json`,
                doc,
                {
                    permissions: xdmp.defaultPermissions(),
                    collections: xdmp.defaultCollections().toArray().concat(['/llamaverse/pastures']),
                }
            )
        },
        {
            "userId": xdmp.user("mother"),
            "update": "true",
            "isolation": "different-transaction"
        }
    )
});

Need Some Help?


Looking for more information on this subject or any other topic related to MarkLogic? Contact Us (info@cleverllamas.com) to find out how we can assist you with consulting or training!