ActiveRecord & Postgresql:查询 jsonb 属性

ActiveRecord & Postgresql: Query jsonb attribute

我有一个模型 Characteristic,它有一个 equivalent 属性,它是一个 jsonb 值。

例如:

characteristic1: 
id:1
equivalent: {list: ['first', 'second', 'third']}

characteristic2: 
id:2
equivalent: {list: ['fourth', 'fifth', 'sixth']}

如何使用活动记录查询接口在列表中找到second的记录?

找到方法:

Characteristic.where("equivalent -> 'list' ? 'second' ")