当键在JSONB字段中时续集加入

发布于 2025-02-13 06:24:13 字数 416 浏览 0 评论 0原文

是否有一种使用方法包括(实际上是联接表)到另一个模型,其中键在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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文