# Neo4j

> Read and change your Neo4j graph: run Cypher queries, create, find, update and delete nodes and relationships, and manage indexes and constraints. Start a workflow when a node or relationship is added or a query's results change.

App · 21 actions. Web page: https://docs.lodol.com/docs/integrations/neo4j

## Actions

### Change node labels

Add labels to, or take labels off, the nodes with a label whose properties have the values given.

**Inputs**

- Label (`label`, text, required): The label the nodes have now.
- Where these match (`match_properties`, object, required): The property values the nodes must have, such as email = alice@example.com. Every one must match.
- Add labels (`add_labels`, list): Labels to add, such as Customer.
- Remove labels (`remove_labels`, list): Labels to take off.
- Database (`database`, text): The database to use. Leave blank for the connection's database.

**Outputs**

- `count` (number): How many nodes matched
- `labels_added` (number): How many labels were added
- `labels_removed` (number): How many labels were taken off
- `nodes` (list): The nodes, as they are now

**Example output**

```json
{
  "count": 1,
  "labels_added": 1,
  "labels_removed": 0,
  "nodes": [
    {
      "element_id": "4:ff04df25-ff2b-4b55-98f8-6888297b025e:0",
      "labels": [
        "Person",
        "Customer"
      ],
      "properties": {
        "age": 42,
        "email": "alice@example.com",
        "name": "Alice Example"
      }
    }
  ]
}
```

### Count nodes

Count the nodes with a label whose properties have the values given.

**Inputs**

- Label (`label`, text): Only nodes with this label. Leave blank for every node.
- Where these match (`match_properties`, object): Only nodes with these property values. Leave empty for every node with the label.
- Database (`database`, text): The database to use. Leave blank for the connection's database.

**Outputs**

- `count` (number): How many nodes match

**Example output**

```json
{
  "count": 1250
}
```

### Create index

Index nodes with a label by one or more properties, so finding them by those values is fast. Nothing changes if the index is already there.

**Inputs**

- Label (`label`, text, required): The label of the nodes to index.
- Properties (`index_properties`, list, required): The properties to index.
- Index name (`index_name`, text): A name for the index. Leave blank for one made from the label and properties.
- Database (`database`, text): The database to use. Leave blank for the connection's database.

**Outputs**

- `created` (true/false): False if an index of that name was already there
- `index_name` (text): The index's name

**Example output**

```json
{
  "created": true,
  "index_name": "Person_email_index"
}
```

### Create node

Create a node with a label and properties.

**Inputs**

- Label (`label`, text, required): The node's label, such as Person. Pick one, or type a new one.
- Properties (`node_properties`, object): The node's properties, such as name = Alice. Each value is text, a number, true or false, or a list of these.
- More labels (`extra_labels`, list): Further labels to give the node, such as Customer.
- Database (`database`, text): The database to use. Leave blank for the connection's database.

**Outputs**

- `node` (object): The node

**Example output**

```json
{
  "node": {
    "element_id": "4:ff04df25-ff2b-4b55-98f8-6888297b025e:0",
    "labels": [
      "Person"
    ],
    "properties": {
      "age": 42,
      "email": "alice@example.com",
      "name": "Alice Example"
    }
  }
}
```

### Create or update node

Find the node with a label and key values, such as an email address, or create it if there is none, then set properties on it.

**Inputs**

- Label (`label`, text, required): The node's label, such as Person.
- Find it by (`key_properties`, object, required): The values that identify the node, such as email = alice@example.com.
- Set when created (`on_create_properties`, object): Properties to set only when the node is new, such as created_at.
- Set when found (`on_match_properties`, object): Properties to set only when the node was already there.
- Database (`database`, text): The database to use. Leave blank for the connection's database.

**Outputs**

- `created` (true/false): True if the node was created, false if it was found
- `node` (object): The node

**Example output**

```json
{
  "created": true,
  "node": {
    "element_id": "4:ff04df25-ff2b-4b55-98f8-6888297b025e:0",
    "labels": [
      "Person"
    ],
    "properties": {
      "age": 42,
      "email": "alice@example.com",
      "name": "Alice Example"
    }
  }
}
```

### Create relationship

Connect a node to another with a relationship, such as a Person WORKS_AT a Company, finding each node by its property values.

**Inputs**

- From label (`from_label`, text, required): The label of the node the relationship starts from.
- From node where (`from_properties`, object, required): Property values that find the start node, such as email = alice@example.com.
- Relationship type (`relationship_type`, text, required): The relationship's type, such as WORKS_AT. Pick one, or type a new one.
- To label (`to_label`, text, required): The label of the node the relationship points to.
- To node where (`to_properties`, object, required): Property values that find the end node, such as name = Acme.
- Relationship properties (`relationship_properties`, object): Properties for the relationship itself, such as since = 2021.
- Skip if already connected (`skip_existing`, true/false): Don't add a second relationship of this type between the same two nodes. Off by default. Default: `false`.
- Database (`database`, text): The database to use. Leave blank for the connection's database.

**Outputs**

- `count` (number): How many relationships the step returned
- `created` (number): How many were new (fewer when existing ones were skipped)
- `relationships` (list): The relationships, each with the nodes at its ends

**Example output**

```json
{
  "count": 1,
  "created": 1,
  "relationships": [
    {
      "from": {
        "element_id": "4:ff04df25-ff2b-4b55-98f8-6888297b025e:0",
        "labels": [
          "Person"
        ],
        "properties": {
          "age": 42,
          "email": "alice@example.com",
          "name": "Alice Example"
        }
      },
      "relationship": {
        "element_id": "5:ff04df25-ff2b-4b55-98f8-6888297b025e:2",
        "end_element_id": "4:ff04df25-ff2b-4b55-98f8-6888297b025e:1",
        "properties": {
          "since": 2021
        },
        "start_element_id": "4:ff04df25-ff2b-4b55-98f8-6888297b025e:0",
        "type": "WORKS_AT"
      },
      "to": {
        "element_id": "4:ff04df25-ff2b-4b55-98f8-6888297b025e:1",
        "labels": [
          "Company"
        ],
        "properties": {
          "name": "Acme Corporation"
        }
      }
    }
  ]
}
```

### Create uniqueness constraint

Require every node with a label to have a different value of a property (or combination of properties). Nothing changes if it is already there.

**Inputs**

- Label (`label`, text, required): The label of the nodes it applies to.
- Properties (`constraint_properties`, list, required): The property, or properties together, that must be unique.
- Constraint name (`constraint_name`, text): A name for the constraint. Leave blank for one made from the label and properties.
- Database (`database`, text): The database to use. Leave blank for the connection's database.

**Outputs**

- `constraint_name` (text): The constraint's name
- `created` (true/false): False if a constraint of that name was already there

**Example output**

```json
{
  "constraint_name": "Person_email_unique",
  "created": true
}
```

### Delete constraint

Delete a constraint. The data stays.

**Inputs**

- Constraint (`constraint_name`, text, required): The constraint to delete. Pick one, or type its name.
- Database (`database`, text): The database to use. Leave blank for the connection's database.

**Outputs**

- `constraint_name` (text): The constraint's name
- `dropped` (true/false): False if there was no constraint of that name

**Example output**

```json
{
  "constraint_name": "Person_email_unique",
  "dropped": true
}
```

### Delete index

Delete an index. The data it indexed stays.

**Inputs**

- Index (`index_name`, text, required): The index to delete. Pick one, or type its name.
- Database (`database`, text): The database to use. Leave blank for the connection's database.

**Outputs**

- `dropped` (true/false): False if there was no index of that name
- `index_name` (text): The index's name

**Example output**

```json
{
  "dropped": true,
  "index_name": "Person_email_index"
}
```

### Delete nodes

Delete the nodes with a label whose properties have the values given, and by default their relationships.

**Inputs**

- Label (`label`, text, required): The label of the nodes to delete.
- Where these match (`match_properties`, object, required): The property values the nodes must have, such as email = alice@example.com. Every one must match.
- Delete their relationships too (`detach`, true/false): On by default. Off refuses to delete a node that still has relationships. Default: `true`.
- Database (`database`, text): The database to use. Leave blank for the connection's database.

**Outputs**

- `nodes_deleted` (number): How many nodes were deleted
- `relationships_deleted` (number): How many of their relationships went with them

**Example output**

```json
{
  "nodes_deleted": 1,
  "relationships_deleted": 2
}
```

### Delete relationships

Delete relationships of a type between the nodes that match, leaving the nodes in place.

**Inputs**

- Relationship type (`relationship_type`, text, required): The type of the relationships to delete.
- From label (`from_label`, text): The label of the node the relationship starts from. Leave blank for any.
- From node where (`from_properties`, object): Property values that find the start node, such as email = alice@example.com. Leave empty for any.
- To label (`to_label`, text): The label of the node the relationship points to. Leave blank for any.
- To node where (`to_properties`, object): Property values that find the end node, such as name = Acme. Leave empty for any.
- Relationship where (`match_properties`, object): Only relationships with these property values.
- Database (`database`, text): The database to use. Leave blank for the connection's database.

**Outputs**

- `relationships_deleted` (number): How many relationships were deleted

**Example output**

```json
{
  "relationships_deleted": 1
}
```

### Find nodes

Find nodes with a label whose properties have the values given, optionally sorted by a property.

**Inputs**

- Label (`label`, text): Only nodes with this label. Leave blank for any label.
- Where these match (`match_properties`, object): Only nodes with these property values. Leave empty for every node with the label.
- Sort by (`order_by`, text): The property to sort by. Leave blank for no order.
- Highest first (`descending`, true/false): Sort from the highest value down. Off sorts lowest first. Default: `false`.
- How many (`limit`, number): The most nodes to return, up to 1000. Defaults to 100. From 1 to 1000.
- Skip (`skip`, number): How many to skip first, to read the next page. Defaults to 0. At least 0.
- Database (`database`, text): The database to use. Leave blank for the connection's database.

**Outputs**

- `count` (number): How many
- `nodes` (list): The nodes

**Example output**

```json
{
  "count": 1,
  "nodes": [
    {
      "element_id": "4:ff04df25-ff2b-4b55-98f8-6888297b025e:0",
      "labels": [
        "Person"
      ],
      "properties": {
        "age": 42,
        "email": "alice@example.com",
        "name": "Alice Example"
      }
    }
  ]
}
```

### Find relationships

Find relationships of a type, with the nodes at each end, optionally only between nodes with given labels and values.

**Inputs**

- Relationship type (`relationship_type`, text): Only relationships of this type. Leave blank for any type.
- From label (`from_label`, text): The label of the node the relationship starts from. Leave blank for any.
- From node where (`from_properties`, object): Property values that find the start node, such as email = alice@example.com. Leave empty for any.
- To label (`to_label`, text): The label of the node the relationship points to. Leave blank for any.
- To node where (`to_properties`, object): Property values that find the end node, such as name = Acme. Leave empty for any.
- Relationship where (`match_properties`, object): Only relationships with these property values.
- How many (`limit`, number): The most to return, up to 1000. Defaults to 100. From 1 to 1000.
- Database (`database`, text): The database to use. Leave blank for the connection's database.

**Outputs**

- `count` (number): How many
- `relationships` (list): The relationships, each with the nodes at its ends

**Example output**

```json
{
  "count": 1,
  "relationships": [
    {
      "from": {
        "element_id": "4:ff04df25-ff2b-4b55-98f8-6888297b025e:0",
        "labels": [
          "Person"
        ],
        "properties": {
          "age": 42,
          "email": "alice@example.com",
          "name": "Alice Example"
        }
      },
      "relationship": {
        "element_id": "5:ff04df25-ff2b-4b55-98f8-6888297b025e:2",
        "end_element_id": "4:ff04df25-ff2b-4b55-98f8-6888297b025e:1",
        "properties": {
          "since": 2021
        },
        "start_element_id": "4:ff04df25-ff2b-4b55-98f8-6888297b025e:0",
        "type": "WORKS_AT"
      },
      "to": {
        "element_id": "4:ff04df25-ff2b-4b55-98f8-6888297b025e:1",
        "labels": [
          "Company"
        ],
        "properties": {
          "name": "Acme Corporation"
        }
      }
    }
  ]
}
```

### List constraints

List the database's constraints, such as properties that must be unique.

**Inputs**

- Database (`database`, text): The database to use. Leave blank for the connection's database.

**Outputs**

- `constraints` (list): The constraints
- `count` (number): How many

**Example output**

```json
{
  "constraints": [
    {
      "entity_type": "NODE",
      "labels_or_types": [
        "Person"
      ],
      "name": "Person_email_unique",
      "owned_index": "Person_email_unique",
      "properties": [
        "email"
      ],
      "type": "UNIQUENESS"
    }
  ],
  "count": 1
}
```

### List databases

List the databases on the server with their status.

**Inputs**: None.

**Outputs**

- `count` (number): How many
- `databases` (list): The databases

**Example output**

```json
{
  "count": 1,
  "databases": [
    {
      "access": "read-write",
      "default": true,
      "home": true,
      "name": "neo4j",
      "status": "online",
      "type": "standard"
    }
  ]
}
```

### List indexes

List the database's indexes, what each covers and whether it is ready.

**Inputs**

- Database (`database`, text): The database to use. Leave blank for the connection's database.

**Outputs**

- `count` (number): How many
- `indexes` (list): The indexes

**Example output**

```json
{
  "count": 1,
  "indexes": [
    {
      "entity_type": "NODE",
      "labels_or_types": [
        "Person"
      ],
      "name": "Person_email_index",
      "owning_constraint": "",
      "properties": [
        "email"
      ],
      "state": "ONLINE",
      "type": "RANGE"
    }
  ]
}
```

### List labels

List every node label in the database.

**Inputs**

- Database (`database`, text): The database to use. Leave blank for the connection's database.

**Outputs**

- `count` (number): How many
- `labels` (list): The labels

**Example output**

```json
{
  "count": 2,
  "labels": [
    "Company",
    "Person"
  ]
}
```

### List property names

List every property name used in the database.

**Inputs**

- Database (`database`, text): The database to use. Leave blank for the connection's database.

**Outputs**

- `count` (number): How many
- `property_keys` (list): The property names

**Example output**

```json
{
  "count": 3,
  "property_keys": [
    "email",
    "name",
    "since"
  ]
}
```

### List relationship types

List every relationship type in the database.

**Inputs**

- Database (`database`, text): The database to use. Leave blank for the connection's database.

**Outputs**

- `count` (number): How many
- `relationship_types` (list): The relationship types

**Example output**

```json
{
  "count": 2,
  "relationship_types": [
    "KNOWS",
    "WORKS_AT"
  ]
}
```

### Run a Cypher query

Run any Cypher statement, with values passed as parameters, and get its rows and what it changed.

**Inputs**

- Cypher query (`query`, text, required): The Cypher statement. Refer to a value given in Parameters as $name rather than typing it in.
- Parameters (`parameters`, object): Values the query uses as $name, such as age = 30.
- Read only (`read_only`, true/false): Refuse to change anything, so a query meant only to read can never write. Off by default. Default: `false`.
- Database (`database`, text): The database to use. Leave blank for the connection's database.

**Outputs**

- `count` (number): How many rows
- `counters` (object): What changed, such as nodesCreated, relationshipsDeleted and propertiesSet
- `fields` (list): The names of the columns
- `notifications` (list): Warnings and hints Neo4j gave about the query
- `query_type` (text): r (read), w (write), rw (read and write) or s (schema)
- `rows` (list): One record per row, keyed by the names the query returns
- `truncated` (true/false): True when more than 10000 rows came back and the rest were left out

**Example output**

```json
{
  "count": 1,
  "counters": {
    "containsUpdates": false,
    "nodesCreated": 0
  },
  "fields": [
    "p.name",
    "p.email"
  ],
  "notifications": [],
  "query_type": "r",
  "rows": [
    {
      "p.email": "alice@example.com",
      "p.name": "Alice Example"
    }
  ],
  "truncated": false
}
```

### Update nodes

Set or clear properties on the nodes with a label whose properties have the values given. Other properties stay as they are.

**Inputs**

- Label (`label`, text, required): The label of the nodes to change.
- Where these match (`match_properties`, object, required): The property values the nodes must have, such as email = alice@example.com. Every one must match.
- Set (`set_properties`, object): The properties to set, such as status = active. An empty value clears that property.
- Clear (`remove_properties`, list): Properties to take off the nodes altogether.
- Database (`database`, text): The database to use. Leave blank for the connection's database.

**Outputs**

- `count` (number): How many nodes matched
- `nodes` (list): The nodes, as they are now
- `properties_set` (number): How many property values were set or cleared

**Example output**

```json
{
  "count": 1,
  "nodes": [
    {
      "element_id": "4:ff04df25-ff2b-4b55-98f8-6888297b025e:0",
      "labels": [
        "Person"
      ],
      "properties": {
        "age": 42,
        "email": "alice@example.com",
        "name": "Alice Example",
        "status": "active"
      }
    }
  ],
  "properties_set": 1
}
```
