In Cypher (Neo4j) you can work with strings, dates, and numbers using built-in functions, just like in SQL or Python.
🔹 1. Working with Strings
Cypher has many string functions.
Examples:
🔹 2. Working with Dates & Times
Neo4j has temporal types: date
, time
, datetime
, localdatetime
, duration
.
Examples:
🔹 3. Working with Numbers
Cypher supports math functions.
Examples:
🔹 4. Mixing Types
You can combine these in queries.
Example:
👉 Shows each user’s name, uppercase version, and age (calculated from birth year).
✨ Tip: Neo4j functions are well-documented here.
this is very important in Neo4j because using parameters makes queries faster, reusable, and safer (avoids injection attacks).
🔹 1. What are Parameters in Cypher?
Instead of hardcoding values in your query, you use placeholders like $paramName
and supply values separately.
✅ Benefits:
-
Query plan can be cached → faster execution.
-
Cleaner queries.
-
Avoids string concatenation (safer).
🔹 2. Basic Example
Without parameter ❌ (hardcoded):
With parameter ✅:
Supplying parameter (example in Neo4j Browser):
Or in code (Python driver):
🔹 3. Multiple Parameters
Set parameters:
🔹 4. Parameters in Relationships
🔹 5. Parameters with Collections
🔹 6. Parameters with Maps
You can even pass property maps:
✅ Summary:
-
$param
→ placeholder in query. -
Values supplied separately (
:param
in browser, dictionary in drivers). -
Works with scalars, lists, and maps.
-
Improves performance & security.
Comments
Post a Comment