queries.hx 893 B

12345678910111213141516171819202122232425
  1. QUERY CreateUser(gh_id: U64, gh_login: String, name: String, email: String) =>
  2. user <- AddN<User>({gh_id: gh_id, gh_login: gh_login, name: name, email: email})
  3. RETURN user
  4. QUERY LookupUser(gh_id: U64) =>
  5. user <- N<User>({gh_id: gh_id})
  6. RETURN user
  7. QUERY CreateCluster(user_id: ID, region: String, instance_type: String, storage_gb: I64, ram_gb: I64) =>
  8. user <- N<User>(user_id)
  9. new_cluster <- AddN<Cluster>({region: region})
  10. new_instance <- AddN<Instance>({
  11. region: region,
  12. instance_type: instance_type,
  13. storage_gb: storage_gb,
  14. ram_gb: ram_gb
  15. })
  16. AddE<CreatedCluster>::From(user)::To(new_cluster)
  17. AddE<CreatedInstance>::From(new_cluster)::To(new_instance)
  18. RETURN new_cluster
  19. QUERY GetInstancesForUser(user_id: ID) =>
  20. instances <- N<User>(user_id)::Out<CreatedCluster>::Out<CreatedInstance>
  21. RETURN instances