apoc.create.virtual.fromNode

Function

apoc.create.virtual.fromNode(node NODE, propertyNames LIST<STRING>) - returns a virtual NODE from the given existing NODE. The virtual NODE only contains the requested properties.

Signature

apoc.create.virtual.fromNode(node :: NODE, propertyNames :: LIST<STRING>) :: NODE

Input parameters

Name Type Default

node

NODE

null

propertyNames

LIST<STRING>

null

Usage Examples

The examples in this section are based on the following graph:

CREATE (a:Account {type: 'checking', ownerName: 'Maria Perez', ownerId: '123456789', accountNumber: 101010101, routingNumber: 10101010, amount: 1000.00, bank: 'Best Bank'});
CREATE (p:Person {name: 'Jane Doe', birthdate: date('1990-01-13'), favoriteColor: 'green', favoriteDessert: 'ice cream', favoriteMusic: 'classical', favoriteBand: 'The Beatles', favoriteVacation: 'beach', favoriteAnimal: 'horse', favoriteBeverage: 'coffee', favoriteFlower: 'lily'});

The apoc.create.virtual.fromNode procedure provides a way to only visualize or return data that is needed, hiding any unnecessary or sensitive pieces.

The example below shows how we can use the procedure to return only the non-sensitive properties from the node above:

apoc.create.virtual.fromNode
MATCH (a:Account {accountNumber: 101010101})
RETURN apoc.create.virtual.fromNode(a, ['type','bank']);
Table 1. Results
account

{"type":"checking","bank":"Best Bank"}

The apoc.create.virtual.fromNode procedure can also be used to simplify nodes with many properties by only displaying ones that are important to the query.

The example below shows an example of this use:

apoc.create.virtual.fromNode
MATCH (p:Person {name: 'Jane Doe'})
RETURN apoc.create.virtual.fromNode(p, ['favoriteColor','favoriteAnimal','favoriteMusic']);
Table 2. Results
favorites

{"favoriteAnimal":"horse","favoriteMusic":"classical","favoriteColor":│

"green"}