Raw SQL queries
We're building January, an all-in-one API development framework that enables you to build, integrate, test, and deploy APIs in one place.
Read more
Read more
Building on the work we did with custom action, we've now added support for raw SQL queries in the database extension (PostgreSQL).
import { sql } from '@extensions/postgresql';
workflow('GetUserProfileWorkflow', {
tag: 'users',
trigger: trigger.http({
method: 'post',
path: '/',
}),
execute: async ({ trigger }) => {
const records = await sql`
SELECT * FROM users
WHERE email = '${trigger.body.email}'
JOIN profiles ON users.id = profiles.userId
`;
return records;
},
});
You don't have to worry about SQL injection attacks, as the query will be serialized using tag functions before being executed.
We're gathering insights around API development and looking forward for your contribution in the survey.