Hi guys, first congratulation, dgraph looks awesome and pretty cool, second I’d like more easy examples, similar to the post opened by katopz, I think than the examples are a bit hard to follow compared to…for instance…the gremlin examples in its wiki, I’d like see how create a basic graphs and query them, maybe the samples in the gremlin wiki would be a good starting point
Now, I’m trying to recreate a basic schema…I want to set boss and employees, my schema would be something like:
scalar (
age:int
address: string
)
type Person {
name: string @index
age: int
address: string
is_boss_of: uid @reverse
}
probably I could create an edge in Person like is_employee_for… but I want to learn about @reverse so if I check the reverse for is_boss_of I could get what is the boss for a node
tom ---- is_boss_of ----> mike
who is the boss of mike
mike <—is_boss_of — (v)
v is tom
how can create this in dgraph?..
can you provide me an example about how get this?..thank you so much!!!
oh works great, thank so much @ashwin95r, I’ve a small question because seems than I’m confused in what must be declared as scalar and what not
for instance
scalar (
age:int
address: string
)
type Person {
name: string
age: int
address: string
friends: uid
}
why in the documentation the age and address type are declare in both places?..what happens if I didn’t include age and address inside the scalar declaratin.
or in the example than I did this before
type Person {
name: string @index
age: int
address: string
is_boss_of: uid @reverse
}
I set the index for the name in the Person type but you remove this and set it as scalar, what is the reason about that
Currently, @index can be specified only in the scalar declarations (so if you want to index some fields, you have to declare them as scalar regardless of whether you define them in objects or not).
Whereas @reverse can be used in scalar declarations or inside object declarations.
PS: I think we’ll modify this to enable specifying @index within objects soon to avoid this redundancy.
I’ve just started using dgraph and I’m trying to build a schema. I tried out the one @ashwin95r put above and tried running it on the UI of v0.7.4 but it gives me Invalid mutation formatting. I also can’t find any more documentation for types in the schema. I’m wondering whether that’s been deprecated already or if there’s just something that I’m missing.
mutation {
schema {
scalar {
age: int @index .
name: string @index .
}
type Person {
name: string .
age: int .
address: string .
boss_of: uid @reverse .
}
}
}
I see. Thanks @ashwin95r! I’m curious, is that written in the release notes or was it just silently deprecated? I spent a bit of time looking for it before asking 'cause I couldn’t find it anywhere.