How to update properties value in the array of jsonb field?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Don2
    New Member
    • May 2022
    • 1

    How to update properties value in the array of jsonb field?

    Q: How to update properties value in the array of jsonb field?

    Hi All,

    I run Postgres13 (PostgreSQL 13.3 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit)

    I have a jsonb field type (fieldname is test), like below JSON array format, how to update is_read properties in extras node to true where the users_pid=1 and is_read = false?
    Code:
    [
     {
       "data": {
       "users_pid": 1,
       "datetime": "2022-05-01 13:10:58",
       "extras": {
         "is_read": false,
         "read_dt": ""
        }
       }
     },
      {
        "data": {
        "users_pid": 3,
        "datetime": "2022-05-23 11:03:22",
        "extras": {
           "is_read": false,
           "read_dt": ""
         }
       }
     },
     {
       "data": {
         "users_pid": 1,
         "datetime": "2022-05-13 11:23:22",
         "extras": {
         "is_read": false,
         "read_dt": ""
        }
      }
     }
    ]
    Last edited by zmbd; May 25 '22, 12:07 AM. Reason: [Z{Placed REQUIRED code formatting}{Put Question inline}{Moved thread to proper forum}]
  • zmbd
    Recognized Expert Moderator Expert
    • Mar 2012
    • 5501

    #2
    Hello Don2 - Welcome to Bytes...
    You haven't included any steps that you've already tried - sort of a pre-requisite that you show what you've already tried along with any errors etc... that will help our experts to put you on the right path - without reinventing the wheel...

    Without that information - it makes people feel like they're being used as an unpaid coding service instead of a friend lending a helping hand.

    Comment

    Working...