pg.query

Exposes the pg library for connecting to a PostgreSQL database.

Parameters

connection:
string | object
Connection configuration
query: string SQL query
params?: any[] Parameters of the query as an array (Optional)

For more information, see the node-postgres documentation .

Returns

Promise that is resolved with the result of the query.

Examples

Insert a row into the 'test_orders' table
module.exports = async function(payload, actions, context) {
	const result = await actions.pg.query(
		process.env.DATABASE_URL,  
		'insert into test_orders (total) values ($1)',
		[ payload.total_price ]
	);
 
 	console.log('Query result: ', result);
}