Book Image

Neo4j Graph Data Modelling

Book Image

Neo4j Graph Data Modelling

Overview of this book

Table of Contents (16 chapters)
Neo4j Graph Data Modeling
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Queries to find the booking history of a user


The query for finding all bookings by a user is straightforward, as shown here:

neo4j-sh (?)$ MATCH (user:User{email:"[email protected]"})-[:MADE_BOOKING]->(b:Booking) RETURN b._id as booking_id;

The output of the preceding query is as follows:

+----------------------------------------+
| booking_id                             |
+----------------------------------------+
| "251679be-1b3f-11e5-820e-6c40089a9424" |
| "ff3dd694-7e7f-11e4-bb93-14109fda6b71" |
| "7c63cc35-7e7f-11e4-8ffe-14109fda6b71" |
| "f5f15252-1b62-11e5-8252-6c40089a9424" |
| "d45de0c2-1b62-11e5-98a2-6c40089a9424" |
| "fef04c30-7e2d-11e4-8842-14109fda6b71" |
| "f87a515e-7e2d-11e4-b170-14109fda6b71" |
| "75b3e78c-7e2b-11e4-a162-14109fda6b71" |
+----------------------------------------+
8 rows

Upcoming journeys of a user

Upcoming journeys of a user is straightforward. We can construct it by simply comparing today's date to the journey date as shown:

neo4j-sh (?)$ MATCH (user:User...