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 json

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

PREVIOUS NEXT
Code Example
Javascript :: angular set timezone 
Javascript :: how to run react code in visual studio 
Javascript :: pass object by value js 
Javascript :: mongoose update array push multiple 
Javascript :: javascript first class functions 
Javascript :: check if file exists javascript 
Javascript :: Auto increment in firebase realtime database 
Javascript :: object.assign in express 
Javascript :: objects in array 
Javascript :: get the max value from array js 
Javascript :: node.js folder structure 
Javascript :: Working of Recursion in C++ 
Javascript :: print a number with commas as thousands separator 
Javascript :: javascripts events 
Javascript :: input type for mobile number in react js 
Javascript :: mdn javascript 
Javascript :: empty array length javascript 
Javascript :: set active element javascript 
Javascript :: how to add function in javascript 
Javascript :: how do you calculate what percentage a number is of another number 
Javascript :: js check for obj property 
Javascript :: fizzbuzz in one line javascript 
Javascript :: JavaScript Change the Elements of an Array 
Javascript :: array reverse with for loop 
Javascript :: javascript page loader 
Javascript :: delete JSON properties in place with jq 
Javascript :: print name time times in javascript 
Python :: abc list 
Python :: opencv show image jupyter 
Python :: how to shutdown a computer with python 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =