SELECT medias,likes,description,createdon,title,postid,type,catagory,out('createdby').Name as Authors ,out('createdby').Nominator.Name as nominator, out('createdby').Nominator.school.Name as school  from post where isDeleted=false order by createdon desc

我必须从每一个帖子中获取细节。
这是我的亲戚
[post]-通过->[student]创建
student表有一个对象名Nominator,它包含Nominator的详细信息,table Nominator有一个名为school的字段,它包含school的详细信息
当我运行上面的命令时,我得到如下输出
[
        {
            "@type": "d",
            "@rid": "#-2:15",
            "@version": 0,
            "medias": "/audience/fileupload/uploads/images/d5f1c692c0a01bd0d308b0cc3aa090cb.jpg",
            "likes": 1,
            "description": "This is art of rabbit ",
            "createdon": "2017-10-23 22:00:27",
            "title": "Rabbit",
            "postid": "0hLU1",
            "type": "photo",
            "catagory": "Art",
            "Authors": [
                "SONISHA M"
            ],
            "nominator": [
                "karthikairani j"
            ],
            "school": [
                "Panchayat union middle school,keelamelkudi"
            ]
        },
        {
            "@type": "d",
            "@rid": "#-2:12",
            "@version": 0,
            "medias": "/audience/fileupload/uploads/images/fd1fe7227d1e6d6bfd455dffddb41db9.jpg",
            "likes": 1,
            "description": "This post of multiple students work on global warming issues ",
            "createdon": "2017-10-23 20:17:55",
            "title": "Global warming ",
            "postid": "BwOk7",
            "type": "photo",
            "catagory": "Art",
            "Authors": [
                "BALANIKUMAR M",
                "YUVARAJ R",
                "SOBIK RAJ C",
                "KALIDASS R"
            ],
            "nominator": [
                "Arokia raj",
                "Arokia raj",
                "Arokia raj",
                "Arokia raj"
            ],
            "school": [
                "Panchayat union middle school,keelamelkudi",
                "Panchayat union middle school,keelamelkudi",
                "Panchayat union middle school,keelamelkudi",
                "Panchayat union middle school,keelamelkudi"
            ]
        }

一个职位可以由许多提名者下的许多学生担任
那么,如果只显示一个提名者的名字,而学校的名字只出现一次,怎么过滤呢
我如何改变我的代码以获得这样的输出我有什么办法可以使它更有效
[
        {
            "@type": "d",
            "@rid": "#-2:15",
            "@version": 0,
            "medias": "/audience/fileupload/uploads/images/d5f1c692c0a01bd0d308b0cc3aa090cb.jpg",
            "likes": 1,
            "description": "This is art of rabbit ",
            "createdon": "2017-10-23 22:00:27",
            "title": "Rabbit",
            "postid": "0hLU1",
            "type": "photo",
            "catagory": "Art",
            "Authors": [
                "SONISHA M"
            ],
            "nominator": [
                "karthikairani j"
            ],
            "school": [
                "Panchayat union middle school,keelamelkudi"
            ]
        },
        {
            "@type": "d",
            "@rid": "#-2:12",
            "@version": 0,
            "medias": "/audience/fileupload/uploads/images/fd1fe7227d1e6d6bfd455dffddb41db9.jpg",
            "likes": 1,
            "description": "This post of multiple students work on global warming issues ",
            "createdon": "2017-10-23 20:17:55",
            "title": "Global warming ",
            "postid": "BwOk7",
            "type": "photo",
            "catagory": "Art",
            "Authors": [
                "BALANIKUMAR M",
                "YUVARAJ R",
                "SOBIK RAJ C",
                "KALIDASS R"
            ],
            "nominator": [
                "Arokia raj"
            ],
            "school": [
                "Panchayat union middle school,keelamelkudi"
            ]
        }

最佳答案

试试这个:

 SELECT medias,likes,description,createdon,title,postid,type,catagory,out('createdby').Name as Authors ,DISTINCT(nominator) as nominator, DISTINCT(school) as school  from (SELECT medias,likes,description,createdon,title,postid,type,catagory,out('createdby').Name as Authors ,out('createdby').Nominator.Name as nominator, out('createdby').Nominator.school.Name as school  from post where isDeleted=false order by createdon desc unwind nominator,school)

09-25 21:28