如何在Loopback 3中的JSON列上应用过滤器?

时间:2019-06-13 14:22:07

标签: loopbackjs

我试图在表的json列上应用过滤器,但无法这样做。我的数据库在Postgres中。行的json列中的数据如下-

 {
    "1": {
        "new": "yes",
        "model": "2019"
    },
    "2": {
        "new": "yes",
        "model": "2015"
    },
    "3": {
        "new": "yes",
        "model": "2012"
    },
    "4": {
        "new": "no",
        "model": "2011"
    },
    "5": {
        "new": "yes",
        "model": "2012"
    }
 }

表中有几行具有相同数据结构的列。 我想应用过滤器,以便在json数据中找到数据时返回相应的行。 例如,在这里我想返回模型为“ 2015”的所有行。如何构造这样的过滤器?有可能吗?

1 个答案:

答案 0 :(得分:0)

对于您而言,此过滤器应如下所示:

YourModel.find({where:{model:2015}})