user6225298
user6225298

Reputation:

COUNT in WHERE loopback

When I call my loopback API on the route /models/?filter={"include":"c"}, I get the following result :

[
{
"a": 1,
    "b": "abc",
    "c": [
      //
    ]
},
{
    "a": 2,
    "b": "def",
    "c": [
      //
    ]
},
{
    "a": 3,
    "b": "xyz",
    "c": [
      //
    ]
}
]

How can I get only the results where the "c" array is empty ? Basically I would like to reproduce a WHERE COUNT(c) = 0 clause.

Upvotes: 0

Views: 3896

Answers (1)

IftekharDani
IftekharDani

Reputation: 3729

You can use LoopBack Where Filter: Link

Example :

/models/?filter={"where":{c: {$size: {$lt:0}}}

Upvotes: 1

Related Questions