当键在JSONB字段中时续集加入
是否有一种使用方法包括(实际上是联接表)到另一个模型,其中键在JSONB
字段中?例如:
item {id:integer,somejsonbfield:jsonb}
(项目示例:{id:1,somejsonbfield:{storeID:2}}}
)
,然后获得所有在带有ID 2的商店项目中,您可以写下类似的内容:
item.findall({inclage:{model:'store',键: 'somejsonbfield.storeid',...}})
ofcourse,在现实世界中,storeid
应直接在item
中,但仅出于目的这个问题 - 怎么办?
Is there a way to use include (which is actually a join table) to another Model, where the key is INSIDE a JSONB
field? for example:
Item { id: INTEGER, someJsonbField: JSONB }
(item example: { id: 1, someJsonbField: { storeId: 2 } }
)
Then, for getting all of the items of store with id 2, you write something like this:
Item.findAll({ include: { model: 'Store', key: 'someJsonbField.storeId', ... } })
OFCOURSE, in a real world scenario, storeId
should be inside Item
directly, but only for the purpose of this question - How could it be done?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论