Skip to content
Graph-oriented store for DynamoDB.
Branch: master
Clone or download
Pull request Compare This branch is 13 commits behind a-h:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
aws
example
graph
rangefield
README.md
node.go
record.go
store.go

README.md

Pregel

A graph-oriented store for DynamoDB.

s, err := pregel.NewStore("eu-west-2", "pregelStoreLocal")
if err != nil {
  fmt.Println(err)
  os.Exit(1)
}

// Register the store's types.
s.RegisterDataType(func() interface{} {
  return &computer{}
})
s.RegisterDataType(func() interface{} {
  return &router{}
})
s.RegisterDataType(func() interface{} {
  return &connection{}
})
s.RegisterDataType(func() interface{} {
  return &Location{}
})

// Create a computer.
fmt.Println("Creating computer node")
err = s.Put(pregel.NewNode("adrian's mac").WithData(computer{
  Brand:         "Apple",
  YearPurchased: 2015,
}))
if err != nil {
  fmt.Println("error creating node", err)
  os.Exit(1)
}

// Create a router and a connection to the mac.
fmt.Println("Creating router node")
routerToMac := pregel.NewEdge("adrian's mac").
  WithData(connection{
    Type: "wifi",
  })
err = s.Put(pregel.NewNode("router").
  WithData(router{
    SSID: "VM675321",
  }).
  WithData(Location{
    Lat: 48.864716,
    Lng: 2.349014,
  }).
  WithChildren(routerToMac))
if err != nil {
  fmt.Println("error creating router", err)
  os.Exit(1)
}

Graph

GraphQL API on the top of Pregel.

Example, get a router, including its location.

{
  get(id: "router") {
    id
    children(first: 100) {
      edges {
        node {
          id
          children(first: 100) {
            edges {
              node {
                id
              }
            }
          }
          data {
						... on Location {
            	lng
              lat
          	}
          }
        }
      }
    }
    parents(first: 100) {
      edges {
        node {
          id
        }
      }
    }
    data {
      ... on Location {
        lng
        lat
      }
    }
  }
}

Example: move the router to Paris.

mutation moveRouterToParis {
  setNodeFields(input: {
    id: "router"
    location: {
      lat: 48.864716
      lng: 2.349014
    }
  }) {
		set
  }
}

Example: Connect a Nintendo Switch in Bruges, but have the parent router.

mutation addSwitch {
  saveNode(node: {
    id: "switch"
    parents: ["router"]
    location: {
      lat: 51.2605905
      lng: 3.0820626
    }
  }){
    id
  }
}
You can’t perform that action at this time.