How to count a type of nodes

type User {
      t.user_id
      t.user_name
      t.gd_to
  }

    type Gds {
        t.guid
        t.guid_to
    }
    t.gd_to: [uid]  @reverse .

i just want to count the nodes of User

{
   result(func: has(t.user_id)){
   uid 
  }
}

but this does not work

{
   result(func: type(User)){
    count(uid)
  }
}

type User may conflict with dgraph’s system User type.

@luke Here is how you can calculate number of nodes. For a schema say

type Person {
  	
    name
    age
    friend
    owns_pet
}

Then the query to get the number of Person Nodes with name would be.

{
      nodeCount(func: has(<name>)) {
        nodeCount: count(uid)
      }
}
1 Like

Thanks ! It works out