Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to get json data in postgresql

-- Give me params.name (text) from the events table
select params->>'name' from events;

-- Find only events with a specific name
select * from events where params->>'name' = 'Click Button';

-- Give me the first index of a JSON array
select params->ids->0 from events;

-- Find users where preferences.beta is true (boolean)
-- This requires type casting preferences->'beta' from json to boolean
select preferences->'beta' from users where (preferences->>'beta')::boolean is true;
Comment

json with postgresql


        
            
        
     SELECT info ->> 'customer' AS customer,
	info -> 'items' ->> 'product' AS product
FROM orders
WHERE CAST ( info -> 'items' ->> 'qty' AS INTEGER) = 2
Comment

postgres json

UPDATE users SET data = jsonb_set(data, '{name}', '"John"');
Comment

postgres sql select from json

SELECT info ->> 'country' FROM address;  -- info.country
Comment

postgres json

UPDATE users SET tags = tags || array['admin'];
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to get MathJax 
Javascript :: how to use cookies in react class component 
Javascript :: ENOENT, no such file or directory 
Javascript :: numeral js 
Javascript :: create global variable inside function JavaScript 
Javascript :: age validation jquery 
Javascript :: moves zeroes 
Javascript :: react navbar material ui 
Javascript :: vue directive 
Javascript :: javascript sort 
Javascript :: How to get previous url in nextjs 
Javascript :: javascript swap 
Javascript :: javascript ISO Date Formats 
Javascript :: cet time zone right now 
Javascript :: match regex 
Javascript :: access shadow root element 
Javascript :: round number javascript 
Javascript :: react.lazy 
Javascript :: Accessing user input through js 
Javascript :: javascript yyyy-mm-dd to mm-dd-yyyy human readable format 
Javascript :: jest test navlink 
Javascript :: networkx get nodes 
Javascript :: How to Use the replace() String Method in javascript 
Javascript :: redirect to dashboard after login in vue 
Javascript :: prisma bigint 
Javascript :: google sheets get ranges 
Javascript :: hide html elements 
Javascript :: node http2 post 
Javascript :: multiply js 
Javascript :: installing babel from command line 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =