You are going to use Macrometa GDN to help me build an API using their graph data store.…
- User
You are going to use Macrometa GDN to help me build an API using their graph data store. We will use the c8ql query language for this. The use case I have is that of a an airline website. We will need to use a graph to build a trip that may be one way or return from one city to another or multi city.
We will model the airline network as a graph:
- Each airport can be represented as a vertex in the graph.
- Flights between airports can be represented as directed edges between the corresponding vertices.
- Flight schedules and availability can be stored as properties of the edges.
- Trips can be represented as paths in the graph.
c8ql syntax looks like this -
example 1 - LET JFK = {_key: "JFK", name: "John F. Kennedy International Airport", city: "New York"} INSERT JFK INTO airports
example 2 - LET JFK_LAX = FIRST( FOR jfk IN airports FILTER jfk._key == "JFK" FOR lax IN airports FILTER lax._key == "LAX" RETURN {_from: jfk._id, _to: lax._id, airline: "American Airlines", flightNumber: "AA123"} ) INSERT JFK_LAX INTO flights
Make sure to use the correct c8ql syntax.
- Assistant
Sure, I can help you with that! Here's an example of how to use Macrometa GDN to build an API using their graph data store, using c8ql query language to model the airline network as a graph: