Get related classes (rest api)

12 views
Skip to first unread message

Fábio Jansen

unread,
May 25, 2020, 1:52:13 PM5/25/20
to Back4App
Assuming i have a class User and a class Profile

The profile class has a field called "sex" and a field called "user" which is a pointer to user class.

If i get the profile endpoint with : https://myapi.back4app.io/classes/Profile i can get the Profile object:


    {
        "results": [
            {
                "objectId": "sIE6lOZP7R",
                "user": {
                    "__type": "Pointer",
                    "className": "_User",
                    "objectId": "asP3EFYSR4"
                },
                "sex": "male",
                "createdAt": "2020-05-25T17:15:49.324Z",
                "updatedAt": "2020-05-25T17:15:49.324Z"
            }
        ]
    }


and if i want to include the user of this profile, i can include with: https://myapi.back4app.io/classes/Perfil?include=user so i get:


    {
        "results": [
            {
                "objectId": "sIE6lOZP7R",
                "user": {
                    "objectId": "asP3EFYSR4",
                    "username": "fabiojansen",
                    "createdAt": "2020-05-25T17:15:16.273Z",
                    "updatedAt": "2020-05-25T17:15:16.273Z",
                    "ACL": {
                        "*": {
                            "read": true
                        },
                        "asP3EFYSR4": {
                            "read": true,
                            "write": true
                        }
                    },
                    "__type": "Object",
                    "className": "_User"
                },
                "sex": "male",
                "createdAt": "2020-05-25T17:15:49.324Z",
                "updatedAt": "2020-05-25T17:15:49.324Z"
            }
        ]
    }


Its ok, but if i want to get all the users, with the profile information in one query? Its possible? In my User class, i dont have any pointer to Profile class, only in profile class.

Is there any way?

Thanks

Davi Macêdo

unread,
May 25, 2020, 10:50:01 PM5/25/20
to Back4App
How are they related? 1 user to 1 profile or can 1 user have multiple profiles?
Reply all
Reply to author
Forward
0 new messages