MATCH (u: User)<-[:USER_PERMISSION]-(p: Permission)
WHERE ID(u)=$userId
RETURN p
I get user and its permissions by userId, simple.
I want to query by name if permissionName is passed in params and if not I just dont put in the where
MATCH (u: User)<-[:USER_PERMISSION]-(p: Permission)
WHERE ID(u)=$userId AND IF($permissionName ? p.name STARTS WITH $permissionName : "")
RETURN p
AWESOME, exactly what I need.
Nice style of thinking.
Using same logic for IN
AND ID(p) IN coalesce($permissionIds, [ID(p)])
And it works.
They should put this in the docs tbh..such a powerful method for optional filters.
I actually used JS to parse the string and remove them, but this is way better
Thanks a lot!!!!