// create a new graph object graph := cayley.NewGraph("bolt", "path/to/graph.db", nil) // execute a query and iterate over its results query := graph.V("alice").Out("likes") iterator := query.Iterate() for iterator.Next() { fmt.Println(iterator.Result()) }
// create a new graph object graph := cayley.NewGraph("bolt", "path/to/graph.db", nil) // execute a query and get the first result query := graph.V("alice").Out("likes") iterator := query.Iterate() if iterator.Next() { fmt.Println(iterator.Result()) }This example shows how to get only the first result of a query. The resulting iterator is used to get the first item, which is then printed to the console. Overall, the Iterator type in the github.com/google/cayley/graph package is useful for iterating over the results of graph queries.