Set attributes for results on Parse Server


I am using Parse Server for an Ionic3/Angular 4 Application.

I perform a query on Cloud Code on Parse Server and I retrieve the results of two Pointer columns.

Table Structure

User ->username

Friends -> toUser(Pointer) -> fromUser (Pointer)

Cloud Code

Parse.Cloud.define('FriendsQuery', function(req,res) {
    const query1 = new Parse.Query("Friends");  
    const query2 = new Parse.Query("Friends"); 
    query1.equalTo("fromUser", { "__type": "Pointer", "className": "_User", "objectId":  req.params.currentuser });
    query2.equalTo("toUser", { "__type": "Pointer", "className": "_User", "objectId":  req.params.currentuser });
    const friendquery = Parse.Query.or(query1, query2);
    friendquery.find().then((results) => {
.catch(() =>  {
  response.error("user lookup failed");


   if (this.currentUser= Parse.User.current()) {
     res => {       
       this.tmp2 = res;
       this.friends = this.localdata.tmpfriends;


Html Code

<ion-item class="item-avatar item-avatar-left item-button-right common-list" *ngFor="let friend of friends">
    <ion-avatar *ngIf="friend.fromUser.objectId ==" item-left><img style="left:0px !important;margin-top:0px !important;" [src]="friend.toUser.avatar  || '/assets/img/no-avatar.png'"/></ion-avatar>
    <ion-label *ngIf="friend.fromUser.objectId ==">{{friend.toUser.username}}</ion-label>
    <ion-avatar *ngIf="friend.toUser.objectId ==" item-left><img style="left:0px !important;margin-top:0px !important;" [src]="friend.fromUser.avatar  || '/assets/img/no-avatar.png'"/></ion-avatar>
    <ion-label *ngIf="friend.toUser.objectId ==">{{friend.fromUser.username}}</ion-label>                

As you can see in hmtl code I have to check the current logged in user to display the right results, his friends.

This is not very wise and this check should be done differently, either on Parse either on a function in order to set an attribute like this:

friend.toUser = something friend.fromUser = something

in order to display in html code something.username to retrieve the friends.

Should I make the check on Cloud Code or locally on a function?

Thank you