【发布时间】:2021-01-29 05:46:44
【问题描述】:
我正在尝试查询 jsonb 数组。
列中的样本数据
[{"entityId": "1ebi", "entityType": "user", "mode": "editor"}, {"entityId": "F13t", "entityType": "team", "mode": "viewer"}]
实体定义
@Column({ name: 'details', type: 'jsonb' })
public details: {entityId: string, entityType: string, mode: string}[];
此查询似乎不起作用。我在看到这个 StackOverflow post 后尝试了这个。但我的数据是 JSON 数组。
this.workbookPermissionRepository
.createQueryBuilder('wp')
.select()
.where('wp.details ::jsonb @> :details', {
details: {
entityType: IPermissionEntityTypes.USER,
entityId: user.slug,
mode: Not(IPermissionSharingModes.NO_ACCESS),
},
})
.printSql()
.getMany();
我在 TypeOrm documentation 中没有找到任何东西。欢迎提出任何建议。
【问题讨论】:
标签: postgresql nestjs jsonb typeorm