Indie Hacking with Postgraphile
@thomasankcorn on Twitter
About Me
@thomasankcorn on Twitter
- Software Engineer at near.st
- Building things makes me feel less incompetent
@IndieHackers
Building things is hard
@thomasankcorn on Twitter
@thomasankcorn on Twitter
Postgraphile
@thomasankcorn on Twitter
What does it do
@thomasankcorn on Twitter
Alternatives
Hasura
@thomasankcorn on Twitter
Postgraphile is the best
@benjie
@jemgillam
@thomasankcorn on Twitter
Sounds awesome in theory...
@thomasankcorn on Twitter
Meat Up
@thomasankcorn on Twitter
@thomasankcorn on Twitter
Constraints
@thomasankcorn on Twitter
CREATE FUNCTION plv8_test (keys text[], vals text[])
RETURNS text
AS $$
var object = {}
for (var i = 0; i < keys.length; i++) {
object[keys[i]] = vals[i]
}
return JSON.stringify(object)
$$
LANGUAGE plv8
IMMUTABLE STRICT;
PostgresQL Functions
PLV8
CREATE FUNCTION app.register_user (first_name text, email text, PASSWORD text)
RETURNS app.user
AS $$
DECLARE
person app.user;
BEGIN
INSERT INTO app.user(first_name, created_at)
values(first_name, now())
RETURNING
* INTO person;
INSERT INTO app_private.account (user_id, email, password_hash)
values(person.id, email, crypt(PASSWORD, gen_salt('bf')));
RETURN person;
END;
$$
LANGUAGE plpgsql
STRICT
SECURITY DEFINER;
PLPSQL
@thomasankcorn on Twitter
Graphile Worker
SELECT graphile_worker.add_job(
'testTask',
json_build_object('name', 'Bobby Tables')
);
@thomasankcorn on Twitter
Deployment
@thomasankcorn on Twitter
@thomasankcorn on Twitter
@thomasankcorn on Twitter
Thanks for listening 🐶
Indie Hacking with Postgraphile
By Thomas Ankcorn
Indie Hacking with Postgraphile
- 312