Examples
This feature has been released as a public beta in AuraDB Enterprise October Release and Neo4j Enterprise Edition 5.13 and breaking changes are likely to be introduced before it is made generally available (GA). |
Selecting entities based on operation type
Changes can be filtered to only return creates, updates or deletes, regardless of whether the effected entity is a node or a relationship.
CALL cdc.query($previousChangeId, [{
select: "e",
operation: "c"
}])
Selecting entities based on changed properties
Changes can be filtered to only include those where a certain property or properties are changed. Note that if a list of properties is provided, for the change to be selected, all of the provided properties need to be changed in the same change event.
CALL cdc.query($previousChangeId, [{
select: "e",
changesTo: ["name"]
}])
CALL cdc.query($previousChangeId, [{
select: "n",
changesTo: ["name"]
}])
CALL cdc.query($previousChangeId, [{
select: "r",
changesTo: ["registerId"]
}])
Selecting entities based on change metadata
Changes can be filtered to only include those where the transaction was carried out by a particular user or certain metadata property or properties have been associated with that transaction.
CALL cdc.query($previousChangeId, [{
select: "e",
executingUser: "alice"
}])
CALL cdc.query($previousChangeId, [{
select: "n",
authenticatedUser: "alice",
executingUser: "bob"
}])
CALL cdc.query($previousChangeId, [{
select: "r",
txMetadata: {
correlationId: 123456789
}
}])
Selecting nodes/relationships by element id
Changes can be filtered to a specific element id. This might be useful when you are interested in changes made to a specific node or relationship. See Cypher Manual → Functions → Scalar functions for more information on getting element ids of existing entities.
CALL cdc.query($previousChangeId, [{
select: "n",
elementId: "4:e239be76-c7e8-43d8-aa03-567de592f426:0"
}])
CALL cdc.query($previousChangeId, [{
select: "r",
elementId: "5:a439fca3-d8b3-35f0-aa49-987fa112f993:0"
}])
Selecting entities by key
Node changes can be filtered to match specified key properties. The provided key properties need to fully match to a corresponding node key or relationship key on the entity. See Capturing key properties for details.
CALL cdc.query($previousChangeId, [{
select: "n",
key: {
name: "Kevin",
surname: "Bacon"
}
}])
CALL cdc.query($previousChangeId, [{
select: "r",
key: {
registerId: 1001
}
}])
If the related constraints are added after a change on an entity is captured, the previous change events are not updated retroactively and do not match key selectors. |
Selecting nodes by label
Node changes can be filtered to specific labels.
CALL cdc.query($previousChangeId, [{
select: "n",
labels: ["Person", "Actor"]
}])
The query above only returns changes on nodes that have both labels. In order to get changes on nodes with either label, two separate selectors have to be specified. See combining selectors for details. |
Selecting relationships by type
Relationship changes can be filtered to a specific type.
CALL cdc.query($previousChangeId, [{
select: "r",
type: "ACTED_IN"
}])
Selecting relationships by start/end nodes
Relationship changes can be selected based on their start and end nodes.
CALL cdc.query($previousChangeId, [{
select: "r",
start: {
labels: ["Person"]
}
}])
CALL cdc.query($previousChangeId, [{
select: "r",
start: {
labels: ["Person"]
},
end: {
labels: ["Movie"]
}
}])
CALL cdc.query($previousChangeId, [{
select: "r",
type: "ACTED_IN",
start: {
labels: ["Person"]
},
end: {
labels: ["Movie"]
}
}])
CALL cdc.query($previousChangeId, [{
select: "r",
start: {
labels: ["Person"],
key: {
name: "john",
surname: "doe"
}
}
}, {
select: "r",
end: {
labels: ["Person"],
key: {
name: "john",
surname: "doe"
}
}
}])
CALL cdc.query($previousChangeId, [{
select: "n",
labels: ["Person"]
}, {
select: "n",
labels: ["Movie"]
}, {
select: "r",
type: "ACTED_IN",
start: {
labels: ["Person"],
},
end: {
labels: ["Movie"],
}
}, {
select: "r",
type: "DIRECTED",
start: {
labels: ["Person"],
},
end: {
labels: ["Movie"],
}
}])
Was this page helpful?