Need a help on Query

We have 3 vertices created for one of the projects - User, Feeds, Comments and below is the query that we are trying to execute:

MATCH {class: Feeds, as: Feeds_data}.out(){as : comments} RETURN Feeds_data:{},comments:{}

This query returns the below response:

{
“result”: [
{
“Feeds_data”: {
“need_moderation”: false,
“feed_category”: “Ad”,
“feed_position”: 1,
“in_userFeeds”: [
#36:2
],
“in_userLikesFeed”: [

            ],
            "out_feedComments": [
                "#34:0",
                "#35:0",
                "#34:1",
                "#35:1"
            ],
            "feed_title": "Buy Dog",
            "feed_id": 2001,
            "content_description": "Any one wants to buy Dog?",
            "feed_subcategory": "General",
            "out_FeedsLocation": [
                "#48:0",
                "#49:1"
            ],
            "feed_interest": "Pets",
            "feed_location_id": "Madhapur",
            "feed_language": "English",
            "in_FeedsLikedByUser": [
                "#38:0"
            ],
            "user_id": 1001,
            "feed_location": "Madhapur",
            "feed_type": "Text"
        },
        "comments": {
            "need_moderation": false,
            "comment_title": "Book Lost",
            "created_on": "2019-07-10 00:00:00",
            "in_feedComments": [
                "#34:0"
            ],
            "in_usersLikeComments": [
                
            ],
            "comment_id": 3001,
            "comment_description": "kadhkdkadkd===lakhdkajdjk lhdkajd jdhjakdgj",
            "feed_id": "2001"
        }
    }

}

We would like to have the details of userFeeds and feedComments also here i.e., instead of below

            "in_userFeeds": [
                "#36:2"
            ],
            "in_userLikesFeed": [
                
            ],
            "out_feedComments": [
                "#34:0",
                "#35:0",
                "#34:1",
                "#35:1"
            ]

We would like to have like this:
“in_userFeeds”: [
"{…Userdetails object}"
],
“in_userLikesFeed”: [
{count of likes}
],
“out_feedComments”: [
"{{
** “need_moderation”: false,**
** “comment_title”: “Book Lost”,**
** “created_on”: “2019-07-10 00:00:00”,**
** “in_feedComments”: [**
** “#34:0”**
** ],**
** “in_usersLikeComments”: [**


** ],**
** “comment_id”: 3001,**
** “comment_description”: “kadhkdkadkd===lakhdkajdjk lhdkajd jdhjakdgj”,**
** “feed_id”: “2001”**
** }}",**
** “{…comments object2}”,**
** “{…comments object3}”,**
** “{…comments object4}”**
]

Can some one please help me with the query ? We tried couple of options using expand but it didnt help.

Regards
Pavan

Hi @pvjpavankumar

did you try with Nested projections?

https://orientdb.com/docs/3.0.x/sql/SQL-Projections.html

You can add for example a nested projection with out('feedComments'){*}

for feed comments details

Hi @wolf4ood,

Thanks a lot for the reply. It worked.

Regards
Pavan

1 Like