# Query
mutation {
update_product(
where: {
uuid: {_eq: "09cf633b-a34c-45cc-ad59-3273e3ad65f3"}
},
_delete_at_path: {
spec: ["frequency_response", "min"]
}
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE FUNCTION update_last_seen_timestamp_func() RETURNS trigger | |
LANGUAGE plpgsql | |
AS $$ | |
BEGIN | |
NEW.last_seen_at := now(); | |
RETURN NEW; | |
END; | |
$$; | |
CREATE TRIGGER update_last_seen_timestamp_trigger |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE VIEW poll_results AS | |
SELECT poll.id AS poll_id, | |
o.option_id, | |
count(*) AS votes | |
FROM (( SELECT vote.option_id, | |
option.poll_id, | |
option.text | |
FROM (vote | |
LEFT JOIN public.option ON ((option.id = vote.option_id)))) o | |
LEFT JOIN poll ON ((poll.id = o.poll_id))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE "user" ( | |
id uuid DEFAULT gen_random_uuid() NOT NULL, | |
created_at timestamp with time zone DEFAULT now() NOT NULL, | |
online_ping boolean, | |
last_seen_at timestamp with time zone | |
); | |
CREATE TABLE poll ( | |
id uuid DEFAULT gen_random_uuid() NOT NULL, | |
created_at timestamp with time zone DEFAULT now() NOT NULL, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE address ( | |
id SERIAL NOT NULL, | |
user_id INTEGER NOT NULL REFERENCES "user" (id), | |
street TEXT, | |
city TEXT, | |
country TEXT, | |
PRIMARY KEY (id) | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE "user" ( | |
"id" SERIAL NOT NULL, | |
"name" TEXT NOT NULL, | |
PRIMARY KEY ("id") | |
); | |
CREATE TABLE address ( | |
id SERIAL NOT NULL, | |
user_id INTEGER NOT NULL REFERENCES "user" (id), | |
street TEXT, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE VIEW laptop_listing AS | |
SELECT | |
name, price, | |
spec->>'processor' AS processor, | |
spec->>'ram' AS ram, | |
spec->>'disk' AS disk, | |
spec->>'display' AS display | |
FROM | |
product | |
WHERE |
# Query
mutation updateProductSpec ($data: jsonb) {
update_product(
where: {
uuid: {_eq: "09cf633b-a34c-45cc-ad59-3273e3ad65f3"}
},
_append: { spec: $data }
) {
affected_rows
# Query
mutation {
update_product(
where: {
uuid: {_eq: "09cf633b-a34c-45cc-ad59-3273e3ad65f3"}
},
_delete_key: {
spec: "driver_units"
}