DEV Community

Dimitrios Desyllas
Dimitrios Desyllas

Posted on

3 1

How to update a postgres jsonb field using eloquent models

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:

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs