weflow-php
v1.0.0
Published
This is a sensitive project. It has a lot of interrelated code. Do not modify without direction.
Downloads
2
Readme
WARNING
This is a sensitive project. It has a lot of interrelated code. Do not modify without direction.
local development
The main trick here is having a postgres database set up with:
cd weflow-php
PHP_ENV=dev php -S localhost:8000
-- SQL function to set a key to a specific value within a json object -- requires PostgreSQL 9.3+
CREATE OR REPLACE FUNCTION "jsonb_object_set_key"( "jsonb" jsonb, "key_to_set" TEXT, "value_to_set" anyelement ) RETURNS jsonb LANGUAGE sql IMMUTABLE STRICT AS $function$ SELECT COALESCE( (SELECT ('{' || string_agg(to_json("key") || ':' || "value", ',') || '}') FROM (SELECT * FROM jsonb_each("jsonb") WHERE "key" <> "key_to_set" UNION ALL SELECT "key_to_set", to_jsonb("value_to_set")) AS "fields"), '{}' )::jsonb $function$;
CREATE OR REPLACE FUNCTION "jsonb_object_delete_keys"("jsonb" jsonb, VARIADIC "keys_to_delete" TEXT[]) RETURNS jsonb LANGUAGE sql IMMUTABLE STRICT AS $function$ SELECT COALESCE( (SELECT ('{' || string_agg(to_json("key") || ':' || "value", ',') || '}') FROM jsonb_each("jsonb") WHERE "key" <> ALL ("keys_to_delete")), '{}' )::jsonb $function$;