youyin123
(Youyin123)
September 13, 2020, 11:13am
1
I now have 10 points and I want to find the end of each point (I know every point has an end point).
I already know how to find one point:
{
# 找到每个点关联到的全部点
var(func: uid(0xfffdf1733b74c2cf)) @recurse(loop: false){
A1 as uid
replyOf
}
# 找到Post点
endnode(func: uid(A1)) @filter(type(Post)){
uid
dgraph.type
}
}
but I don’t know how to find 10 points?
MichelDiz
(Michel Diz)
September 13, 2020, 5:01pm
2
What do you mean by “points”? do you mean “10 connections”? or do you mean actual points? like “10 points for gryffindor”?
youyin123
(Youyin123)
September 14, 2020, 12:05pm
3
@MichelDiz
In fact, what I need to do is such a thing(message = Post + Comment):
the relationship like this:
My logic is:
Find the start person’s last 10 messages 【I’ve done it】
# 找到这个人最近创作的帖子(发帖或评论)
var(func: eq(id, 10995116284808))@cascade @filter(type(Person)){
~hasCreator @filter(type(Comment) or type(Post)) (orderdesc: creationDate, first: 10){
A1 as uid
dgraph.type
}
find the original post of these 10 messages.I found all the relevant information through the side reply:
# 找到每个点关联到的全部点
var1(func: uid(A1)) @recurse(loop: false){
uid
replyOf
dgraph.type
}
the result like:
{
"data": {
"var1": [
{
"uid": "0xfffdf1733b74c2cf",
"replyOf": [
{
"uid": "0xfffdf1733b781e32",
"replyOf": [
{
"uid": "0xfffdf1733b781e2b",
"dgraph.type": [
"Post"
]
}
],
"dgraph.type": [
"Comment"
]
}
],
"dgraph.type": [
"Comment"
]
},
but I just want the end node, that is, the node where the type is the post, what should I do?
ps: The correct result should be the Post corresponding to each Message. You can’t put the posts together without knowing which Message belongs to which Post
Can dgraph do it?