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)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

AWS GenAI Live!

GenAI LIVE! is a dynamic live-streamed show exploring how AWS and our partners are helping organizations unlock real value with generative AI.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️