To query all known shards, we will have to use two other functions:
- fabric.graphIds(), which returns all the known databases. You can test its result with the following command:
RETURN fabric.graphIds()
- fabric.graph(graphId) returns the name of the database with a given ID, directly usable in a Use statement.
This will essentially allow us to perform a loop over all our shards:
UNWIND fabric.graphIds() AS graphId
CALL {
USE fabric.graph(graphId)
WITH graphId
MATCH (order:Order)<--(:User)-->(country:Country)
RETURN "gr" + graphId as db,
country.name as countryName,
count(*) AS nbOrders
} RETURN db, countryName, sum(nbOrders)
Here is the result of the preceding query:
╒═════╤═════════════╤══════════&...