Messenger Dgraph Schema

Populating the database

{
  set {
     _:location <type> "location" .
      _:location <name> "Ken Garf" .
      _:chatRoom <type> "chatRoom" .
      _:chatRoom <phoneNumber> "+12083571222".
      _:location <comunicates_via> _:chatRoom .
      _:conversation <type> "conversation" .
      _:message <type> "message" .
      _:message <body> "Hello, how are you" .
      _:message_2 <type> "message".
      _:message_2 <body> "great" .
      _:conversation <has_item> _:message .
      _:conversation <has_item> _:message_2 .
  }
}

Find all the conversations/items for a location

{
  loc(func: eq(type, "location")) {
    name
    comunicates_via {
      type
      phoneNumber
      has_conversation {
        type
        has_item(orderasc: body) {
          body
          type
          
        }
      }
    }
  }
}