在 Postgresql JSON 数组字段中查找序列
我有 PostgreSQL 数据库,其 JSONB 类型字段名为“元数据”,该字段具有以下内容结构:
row1: {
"name": "test",
"description": "test",
"attributes" : [ { "type": "level" , "level": 1 }, { "type": "name" , "name": "Fish" } ]
}
row2: {
"name": "test2",
"description": "test2",
"attributes" : [ { "type": "level", "level": 4 }, { "type": "name" , "name": "Cat" } ]
}
row3: {
"name": "test4",
"description": "test4",
"attributes" : [ { "type": "level", "level": 7 }, { "type": "name" , "name": "Dog" } ] }
我尝试使用 Sequelize 在 [1, 5] 之间按 attribute.level 进行筛选,发出 findAll 查询请求,但没有得到一些结果。如何在json数组之间查找?
I have PostgreSQL database with JSONB type field named "metadata" that has following content structure:
row1: {
"name": "test",
"description": "test",
"attributes" : [ { "type": "level" , "level": 1 }, { "type": "name" , "name": "Fish" } ]
}
row2: {
"name": "test2",
"description": "test2",
"attributes" : [ { "type": "level", "level": 4 }, { "type": "name" , "name": "Cat" } ]
}
row3: {
"name": "test4",
"description": "test4",
"attributes" : [ { "type": "level", "level": 7 }, { "type": "name" , "name": "Dog" } ] }
I try to make findAll query request with filter by attributes.level between [1, 5] using Sequelize, but don't get some results. how find between json array?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这里它是一个参数化查询。
:lo
和:hi
是参数。the_table
CTE 代表真实表,以供说明。Here it is as a parameterized query.
:lo
and:hi
are parameters.the_table
CTE stands for the real table as an illustration.