We have community nodes. and user nodes. And between them we have a FOLLOWS relation. A user follows a relation. And on that relation we are storing some data. I am making out a query where we have a specific user and a condition that can match multiple communities. I am fetching community , follow count ( follow count is - count of all users that follows matches communities ) and also the follow data between that specific user and all matched communities. I am using below query but it does not provides any data but we have records which matches provided data.
QUERY BELOW
MATCH (u:USER) WHERE u.email='${user}'
MATCH (community:COMMUNITY:FEATURE)
WHERE community.deleted_at IS NULL
AND community.name =~ "(?i).${community_name}."
MATCH (u)-[follows:FOLLOWS]->(community)
CALL {
WITH community
MATCH follows = (community)-[:FOLLOWS]-(:USER)
RETURN COUNT(follows) as follow_count
}
RETURN community,follow_count, exists((u)-[:FOLLOWS]-(community)) as is_community_followed,follows as relationship_data
ORDER BY community.created_at DESC
SKIP ${offset}
LIMIT ${limit}