在JSONB日期字段上过滤LoopBack API

时间:2018-05-27 14:27:56

标签: postgresql loopbackjs

我有一个模型“Test”,它包含另一个模型“General”作为类型对象。 DB:PostgreSQL

{
    "name": "Test",
    "base": "PersistedModel",
    "properties": {
        "srNo": {
            "type": "string"
        },
        "genDetail": {
            "type": "General"
        }
    }
}

{
    "name": "General",
    "base": "PersistedModel",
    "properties": {
        "country": {
            "type": "string"
        },
        "accntOpenDate": {
            "type": "date"
        }
    }
}

我通过测试模型和通用模型数据发布了数据。 整个数据存储在测试模型中,通用模型数据存储在JSONB中。 现在我想根据JSONB中的日期字段进行过滤。 能够对字符串字段[country]进行过滤。

filter : {"where":{"genDetail.country": "INDIA"}}

但对于日期字段,当我尝试使用类似的查询时,会收到错误。

filter : {"where":{"genDetail.accntOpenDate": {"lte": "2017-05-24"}}}
{
  "error": {
    "name": "error",
    "status": 500,
    **"message": "operator does not exist: text <= timestamp with time zone",**
    "length": 232,
    "severity": "ERROR",
    "code": "42883",
    "hint": "No operator matches the given name and argument type(s). You might need to add explicit type casts.",
    "position": "540",
    "file": "src\\backend\\parser\\parse_oper.c",
    "line": "722",
    "routine": "op_error",
    "stack": "error: operator does not exist: text <= timestamp with time zone\n    at Connection.parseE (D:\\EVFoundation\\CHECKLIST\\collaterals\\node_modules\\pg\\lib\\connection.js:567:11)\n    at Connection.parseMessage (D:\\EVFoundation\\CHECKLIST\\collaterals\\node_modules\\pg\\lib\\connection.js:391:17)\n    at Socket.<anonymous> (D:\\EVFoundation\\CHECKLIST\\collaterals\\node_modules\\pg\\lib\\connection.js:129:22)\n    at emitOne (events.js:116:13)\n    at Socket.emit (events.js:211:7)\n    at addChunk (_stream_readable.js:263:12)\n    at readableAddChunk (_stream_readable.js:250:11)\n    at Socket.Readable.push (_stream_readable.js:208:10)\n    at TCP.onread (net.js:594:20)"
  }
}

0 个答案:

没有答案