.. _is_endpoint_of: is_endpoint_of ============== **is_endpoint_of** restricts a Find* command to endpoints of connections referenced earlier in the same transaction. Unlike :ref:`is_connected_to `, its **ref** identifies connections, not objects. .. _is_endpoint_of-fields: Field contract ++++++++++++++ The value is a single relationship object or an object containing one ``all`` or ``any`` array of relationship objects. Wrapper keys cannot be mixed with direct fields. ``{}``, ``{"all": []}``, and ``{"any": []}`` add no relationship restriction. .. list-table:: :header-rows: 1 :widths: 22 22 56 * - Field - Type / required - Behavior * - ``ref`` - integer / required - A reference to connections selected earlier in this transaction. * - :ref:`class ` - object / optional - Match any of the stored connection's class names in ``src``, ``connection``, or ``dst``. * - ``target`` - object / optional - Match the stored connection's endpoint object types in ``src`` or ``dst``. * - ``connection_class`` - string / optional - Shorthand for a ``class`` object with only ``connection``. Supply one class selector per relationship. * - ``direction`` - string / optional - Default any; accepts in, out, or any. Direction is interpreted as described below. * - ``constraints`` - expression array / optional - Omitted: no property filter on the connections. Parameters ++++++++++ Each referenced-connection object supports: * :ref:`ref `: A reference to connections created or found earlier in the transaction. * **direction**: Which endpoint to select. ``out`` selects the source, ``in`` selects the destination, and ``any`` selects both. The default is ``any``. * **connection_class**: Optionally restrict the referenced connections by class. * :ref:`constraints `: Optionally restrict the referenced connections by their properties. The constraint accepts the same single, **any**, and **all** forms as :ref:`is_connected_to `. For multiple specifications, put the referenced-connection objects in an **any** or **all** array. Each entry accepts the fields listed above. For **any**, the endpoint sets produced by the entries are combined. For **all**, they are intersected. The resulting set is then intersected with the Find command's class, property, and :ref:`is_connected_to ` constraints. When :ref:`group_by_source ` is enabled together with **is_connected_to**, endpoint constraints filter the matched objects while the groups continue to come from the object references in **is_connected_to**. **is_endpoint_of** alone does not define source groups. Example +++++++ The following returns Jane, who is both the source endpoint of the ``Knows`` connection and the destination endpoint of the connection created in 2021: .. TESTED_EXAMPLE: is_endpoint_of_1 .. code-block:: json [{ "AddEntity": { "_ref": 1, "class": "Person", "properties": { "name": "Jane" } } }, { "AddEntity": { "_ref": 2, "class": "Person", "properties": { "name": "John" } } }, { "AddEntity": { "_ref": 5, "class": "Person", "properties": { "name": "Alice" } } }, { "AddConnection": { "_ref": 3, "class": "Knows", "src": 1, "dst": 2 } }, { "AddConnection": { "_ref": 4, "class": "Knows", "src": 5, "dst": 1, "properties": { "since_year": 2021 } } }, { "FindEntity": { "with_class": "Person", "is_endpoint_of": { "all": [{ "ref": 3, "direction": "out", "class": { "src": "Person", "connection": "Knows", "dst": "Person" }, "target": { "src": "entity", "dst": "entity" } }, { "ref": 4, "direction": "in", "constraints": ["$since_year", ">=", 2020] }] }, "results": { "list": ["name"] } } }] Result from the query: .. TESTED_EXAMPLE: is_endpoint_of_1_response .. code-block:: json [{ "AddEntity": { "status": 0 } }, { "AddEntity": { "status": 0 } }, { "AddEntity": { "status": 0 } }, { "AddConnection": { "status": 0 } }, { "AddConnection": { "status": 0 } }, { "FindEntity": { "entities": [{ "_class": "Person", "name": "Jane" }], "returned": 1, "status": 0 } }]