how to get Deep data but filter a sub collection

86 Views Asked by At

I have an object which has many sub collections, one of the sub collections usually has more than 100 items and each of those have multiple nested objects. So I want to get deep data of the object but filter out just one sub collection so the response time and data gets minimised.

I want deep data of an object but I want to prevent Backand to get deep inside one of sub collection.

{
 sub_A:[1,2,3],
 sub_B:[1,2,3],
 sub_C:[1,2,3],
 sub_D:[1,2,3],
}

let say in the above object is it possible to get all except sub_D

1

There are 1 best solutions below

2
relly On

You cannot use filter with deep, however you can create an on-demand action for that. Here is an example for user with many items:

function backandCallback(userInput, dbRow, parameters, userProfile) {
    // get the user main level information    
    var user = $http({
        method: "GET",
        url: CONSTS.apiUrl + "/1/objects/users/" + parameters.userId
    });

    // get the user's  related items    
    var userItems = $http({
        method: "GET",
        url: CONSTS.apiUrl + "/1/objects/items",
        params: {
            filter: [{
                fieldName: "user",
                operator:"in",
                value:user.id
            },
            {
                fieldName: "name",
                operator:"contains",
                value:parameters.namePart
            }]
        }
    });

    // get the user's  related items    
    user.items = userItems.data;

    return user;
}