How to use the neo4j.Node function in neo4j

To help you get started, we’ve selected a few neo4j examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github technige / py2neo / src / py2neo / batch.py View on Github external
def result(value, graph_db):
    try:
        metadata = value["body"]
        if "type" in metadata:
            entity = neo4j.Relationship(metadata["self"], graph_db=graph_db)
        else:
            entity = neo4j.Node(metadata["self"], graph_db=graph_db)
        entity._metadata = rest.PropertyCache(metadata)
        return entity
    except KeyError:
        raise ValueError(value)
github technige / py2neo / src / py2neo / batch.py View on Github external
def creator(id, value, graph_db):
    if isinstance(value, dict):
        return {
            "method": "POST",
            "to": "/node",
            "id": id,
            "body": value
        }
    try:
        if isinstance(value[0], neo4j.Node):
            value[0]._must_belong_to(graph_db)
            start_node_uri = relative_uri(value[0]._lookup("self"), "/node")
        else:
            start_node_uri = "{" + str(value[0]) + "}"
        if isinstance(value[2], neo4j.Node):
            value[2]._must_belong_to(graph_db)
            end_node_uri = relative_uri(value[2]._lookup("self"), "/node")
        else:
            end_node_uri = "{" + str(value[2]) + "}"
        return {
            "method": "POST",
            "to": start_node_uri + "/relationships",
            "id": id,
            "body": {
                "to": end_node_uri,
                "data": value[3] if len(value) > 3 else {},