Trying to run the following query:
MATCH(u:User)
OPTIONAL MATCH (u)-[:USER_TYPE]->(adminType:UserType {type:'Admin'})
OPTIONAL MATCH (u)-[:USER_TYPE]->(userType:UserType {type:'User'})
RETURN DISTINCT { adminCount: count(adminType), userCount: count(userType) }
This returns me the count of the admins, but the users are 0. If I switch the OPTIONAL MATCH and set the user first, then I get a count for the user, but not the admin. How do I get of both?
Usernodes in your query. To get the counts of each type, you just need to do something like the following (without involvingUsernodes at all):MATCH (adminType:UserType {type:'Admin'}) WITH count(*) AS adminCount MATCH (userType:UserType {type:'User'}) RETURN {adminCount: adminCount, userCount: COUNT(*)}- cybersam