Have a table Profile with a column named records which is ARRAY of JSONB. The records column is in the following shape:
[
{
itemId: 1,
value: true,
insertOn: '2018-03-26T03:49:55.121Z',
},
{
itemId: 1,
value: false,
insertOn: '2018-03-27T03:49:55.121Z',
},
];
What I am looking forwards to find is the latest value of a given itemId. For example, the latest value of itemId 1 is false.
How can I implement the query? I've tried sequelize.fn('UNNEST', sequelize.col('records')) but dont know how to continue.