问题描述
我目前有这个查询:
OPTIONAL MATCH (t)<-[r:CHILD_OF]-(t1:Thing)<-[:TAGGED]-(post:Post)
后来我有
OPTIONAL MATCH (this)<-[:TAGGED]-(post:Post)
并且因为它们都一起返回(作为帖子列表),我不知道哪些帖子是事物的子级,或者哪些只是直接标记了“这个”。
这里的“CHILD_OF”关系变量名“r”存在时是否可以返回?
完整的帖子看起来像这样:
OPTIONAL MATCH (this)<-[:CHILD_OF]-(t1:Thing)<-[:TAGGED]-(post:Post)
WITH COLLECT(post) as rows,this
OPTIONAL MATCH (this)<-[:TAGGED]-(p:Post)
WITH rows + COLLECT(p) as allRows
UNWIND allRows as post
RETURN disTINCT post
ORDER BY post.date DESC
我不希望它作为地图,因为 neo4j-graphql-js 不支持它,它们只支持返回单个节点。所以我也不能做回帖,r
type Thing {
id: ID!,name: String,description: String,image: String,followers: [User] @relation(name: "FOLLOWS",direction: "IN"),posts: [Post] @cypher(statement: """
OPTIONAL MATCH (this)<-[:CHILD_OF]-(t1:Thing)<-[:TAGGED]-(post:Post)
WITH COLLECT(post) as rows,this
OPTIONAL MATCH (this)<-[:TAGGED]-(p:Post)
WITH rows + COLLECT(p) as allRows
UNWIND allRows as post
RETURN disTINCT post
ORDER BY post.date DESC
""")
}
type User {
id: ID!,uid: String,email: String,bio: String,direction: "OUT"),post_count: Int @cypher(statement: """
MATCH (this)-[:WROTE]->(p:Post)
RETURN count(p)
"""),homepage_posts: [Post] @cypher(statement: """
OPTIONAL MATCH (this)-[r:FOLLOWS]->(something)-[:WROTE|TAGGED]-(post:Post)
WITH COLLECT(post) as rows
OPTIONAL MATCH (this)-[:WROTE]->(post:Post)
WITH rows + COLLECT(post) as allRows
UNWIND allRows as post
RETURN disTINCT post
ORDER BY post.date DESC
""")
}
type Relationship {
type: String
}
type Post {
id: ID!,body: String,images: [String],date: DateTime,isRetweet: Boolean,rating: Float,relationship: Relationship,author: User @relation(name: "WROTE",things: [Thing] @relation(name: "TAGGED",likes: [User] @cypher(statement: """
MATCH (u:User)-[r:LIKES]->(this)
RETURN u
"""),}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)