Revision 48ad042083b8bca89eec4dae96dd78416d8c8776 authored by Iddan Aaronsohn on 22 October 2019, 21:50:39 UTC, committed by Iddan Aaronsohn on 22 October 2019, 22:17:08 UTC
1 parent 9c79218
main.go
package main
import (
"fmt"
"log"
"github.com/cayleygraph/cayley"
"github.com/cayleygraph/quad"
)
func main() {
// To see how most of this works, see hello_world -- this just add in a transaction
store, err := cayley.NewMemoryGraph()
if err != nil {
log.Fatalln(err)
}
// Create a transaction of work to do
// NOTE: the transaction is independent of the storage type, so comes from cayley rather than store
t := cayley.NewTransaction()
t.AddQuad(quad.Make("food", "is", "good", nil))
t.AddQuad(quad.Make("phrase of the day", "is of course", "Hello World!", nil))
t.AddQuad(quad.Make("cats", "are", "awesome", nil))
t.AddQuad(quad.Make("cats", "are", "scary", nil))
t.AddQuad(quad.Make("cats", "want to", "kill you", nil))
// Apply the transaction
err = store.ApplyTransaction(t)
if err != nil {
log.Fatalln(err)
}
p := cayley.StartPath(store, quad.String("cats")).Out(quad.String("are"))
err = p.Iterate(nil).EachValue(nil, func(v quad.Value) {
fmt.Println("cats are", v.Native())
})
if err != nil {
log.Fatalln(err)
}
}
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...