Path building
Building a path of hops between related items
In the following use case example of related items in separate collections for a HVAC system, you can query the nodes up to the end of the path you construct in your request.
Note: In the following example, there are two paths because the related items in each collection share the same
_relatedUserTypename value.

Sample request
{
"$findWithRelatedGraph": {
"start": {
"collectionDesc": {
"_userItemId": "systems_zEfhiXo4wE"
},
"query": {
"_id": "61d2c4fddd6a323c1aee8914"
},
"options": {
"page": {},
"project": {
"_id": 1,
"System Name": 1
}
}
},
"to": {
"segments": [
{
"relatedDesc": {
"_relatedUserType": "iaf_ext_sysel_coll"
},
"as": "sys_elem",
"options": {
"project": {
"System Element Name": 1
}
}
},
{
"from": "sys_elem",
"relatedDesc": {
"_relatedUserType": "rvt_elements"
},
"as": "model_elem"
},
{
"from": "model_elem",
"relatedDesc": {
"_relatedUserType": "rvt_element_props"
},
"options": {
"project": {
"properties": 1
}
},
"as": "model_elem_props"
}
],
"as": "paths",
"response": "path",
"options": {
"page": {
"_offset": 0
}
}
}
}
}
Sample response
{
"_list": [
{
//The collection that contains the start node
"_uri": "/nameduseritems/61d2c4fcdd6a323c1aee890c",
"_name": "systems",
"_userType": "iaf_ext_sys_coll",
"_tipId": "61d2c4fcdd6a323c1aee890d",
"_versions": [ //The collection versions
{
//start node collection tip version
"_userItemDbId": "61d2c4fcdd6a323c1aee890c",
"_relatedItems": {
"_pageSize": 1,
"_list": [
{
"paths": {
"_pageSize": 2,
"_list": [
//first path
{
//first hop
"_userItemId": "system-elements_TEYZX2iPTz",
"_userItemVersionId": "61d2c4fcdd6a323c1aee890f",
"_id": "61d2c4fddd6a323c1aee8915",
"_version": 1,
"child": { //second hop
"_userItemId": "1801ks-inv-_ba_elem_gKARtcrV3q",
"_userItemVersionId": "61d2c4fcdd6a323c1aee8911",
"_id": "61d2c4fddd6a323c1aee891a",
"_version": 1,
"child": { //third hop
"_userItemId": "1801ks-inv-_elprops_i15EmQgrzu",
"_userItemVersionId": "61d2c4fcdd6a323c1aee8913",
"_id": "61d2c4fedd6a323c1aee8920",
"_version": 1
}
}
},
//second path
{
"_userItemId": "system-elements_TEYZX2iPTz",
"_userItemVersionId": "61d2c4fcdd6a323c1aee890f",
"_id": "61d2c4fddd6a323c1aee8916",
"_version": 1,
"child": { //second hop
"_userItemId": "1801ks-inv-_ba_elem_gKARtcrV3q",
"_userItemVersionId": "61d2c4fcdd6a323c1aee8911",
"_id": "61d2c4fddd6a323c1aee891b",
"_version": 1,
"child": { //third hop
"_userItemId": "1801ks-inv-_elprops_i15EmQgrzu",
"_userItemVersionId": "61d2c4fcdd6a323c1aee8913",
"_id": "61d2c4fedd6a323c1aee8921",
"_version": 1
}
}
}
],
"_offset": 0,
"_total": 2
},
"_id": "61d2c4fddd6a323c1aee8914",
"System Name": "HVAC"
}
],
"_offset": 0,
"_total": 1
},
"_id": "61d2c4fcdd6a323c1aee890d",
"_isTip": true,
"_metadata": {
"_updatedById": "f5cca02a-a515-48ed-aea2-37637376416a",
"_createdAt": 1641202940843,
"_createdById": "f5cca02a-a515-48ed-aea2-37637376416a",
"_updatedAt": 1641202940843
},
"_version": 1
}
],
"_irn": "itemsvc:nameduseritem:61d2c4fcdd6a323c1aee890c",
"_namespaces": [
"lnt_EvqksGPz"
],
"_nextVersion": 2,
"_shortName": "systems",
"_tipVersion": 1,
"_versionsCount": 1,
"_itemClass": "NamedUserCollection",
"_userItemId": "systems_zEfhiXo4wE",
"_id": "61d2c4fcdd6a323c1aee890c",
"_metadata": {
"_updatedById": "f5cca02a-a515-48ed-aea2-37637376416a",
"_createdAt": 1641202940840,
"_createdById": "f5cca02a-a515-48ed-aea2-37637376416a",
"_updatedAt": 1641202940840
},
"_kind": "collection"
}
],
"_referencedItems": {//projection of all RelatedItems in each hop, grouped by userItemId and versionId
"system-elements_TEYZX2iPTz": { //collection userItemId
"61d2c4fcdd6a323c1aee890f": { //collection versionId
//nodes in collection
"61d2c4fddd6a323c1aee8916": {
"System Element Name": "Duct",
"_id": "61d2c4fddd6a323c1aee8916"
},
"61d2c4fddd6a323c1aee8915": {
"System Element Name": "AHU1",
"_id": "61d2c4fddd6a323c1aee8915"
}
}
},
"1801ks-inv-_elprops_i15EmQgrzu": { //collection userItemId
"61d2c4fcdd6a323c1aee8913": { //collection versionId
//nodes in collection
"61d2c4fedd6a323c1aee8920": {
"_id": "61d2c4fedd6a323c1aee8920",
"properties": {
"prop": "testValue1"
}
},
"61d2c4fedd6a323c1aee8921": {
"_id": "61d2c4fedd6a323c1aee8921",
"properties": {
"prop1": "testValue1"
}
}
}
},
"1801ks-inv-_ba_elem_gKARtcrV3q": { //collection userItemId
"61d2c4fcdd6a323c1aee8911": { //collection versionId
//nodes in collection
"61d2c4fddd6a323c1aee891a": {
"_id": "61d2c4fddd6a323c1aee891a"
},
"61d2c4fddd6a323c1aee891b": {
"_id": "61d2c4fddd6a323c1aee891b"
}
}
}
},
"_time": "132ms"
}