DEV Community

loading...

How to update a postgres jsonb field using eloquent models

pcmagas profile image Dimitrios Desyllas ・1 min read

Hello may I have some help on this?

I have the following table in my postgresql database:

OOSama:
ID: AUTOINCREMENT BIGINT
NAME: VARCHAR(255)
NANI_WO_SUKI: JSONB

The NANI_WO_SUKI fields can contain the follwowing JSON:

{
  "kodomo":false,
  "dagashi":true,
  "kurosakikun":true
}

So I want to be able to update it without using raw SQL query. So I made the following model:

Discussion (0)

pic
Editor guide