0

I'm getting below response from loopback when I filter with below api:

http://localhost:8001/myloopback/productDetails?q=product.productId==apple

I want to exclude the data which doesn't have property "productModel" - how can we achieve this in Loopback rest API. Is there any option to exclude property from the rest API query param? I'm new to Loopback - it would be really grateful if someone can help me to fix this

{
    "myData": [{
            "data": {
                "product": {
                    "productId": "apple",
                    "productName": "iPhone",
                    "productModel": "6s"
                },
                "statusCode": "active",
                "date": "2018-08-07T00:00:00.000Z"
            },
            "links": [{
                    "productUrl": "test"
                },
                {
                    "productImage": "test"
                }
            ],
            "info": {}
        },
        {
            "data": {
                "product": {
                    "productId": "apple",
                    "productName": "iPhone",
                    "productModel": "7"
                },
                "statusCode": "active",
                "date": "2018-08-07T00:00:00.000Z"
            },
            "links": [{
                    "productUrl": "test"
                },
                {
                    "productImage": "test"
                }
            ],
            "info": {}
        },
        {
            "data": {
                "product": {
                    "productId": "apple",
                    "productName": "Macbook"
                },
                "statusCode": "active",
                "date": "2018-08-07T00:00:00.000Z"
            },
            "links": [{
                    "productUrl": "test"
                },
                {
                    "productImage": "test"
                }
            ],
            "info": {}
        }
    ],
    "metadata": {
        "count": 3,
        "offset": 0
    }
}
learn groovy
  • 487
  • 4
  • 11
  • 28

1 Answers1

0

There is no such inbuilt function to do that but you can use multiple Fields filter to achieve that.

Sookie Singh
  • 1,543
  • 11
  • 17