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
-- the function to call when the trigger is invoked | |
CREATE FUNCTION trigger_on_note_revision() | |
RETURNS TRIGGER | |
LANGUAGE PLPGSQL AS $BODY$ | |
BEGIN | |
-- Create revision only if node's subject or body columns have changed | |
IF OLD.title <> NEW.title OR OLD."data" <> NEW."data" THEN | |
INSERT INTO note_revision (note_id, created_at, title, "data") | |
VALUES (OLD.id, OLD.updated_at, OLD.title, OLD."data"); | |
NEW.updated_at = now(); |
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 the function | |
CREATE FUNCTION insert_deposit() | |
RETURNS trigger AS $BODY$ | |
DECLARE active_account BOOLEAN; | |
BEGIN | |
IF NEW."deposit_amount" <= 0 THEN | |
RAISE EXCEPTION 'Deposit amount must be greater than 0'; | |
END IF; | |
SELECT a.is_active INTO active_account FROM "account_savings" a WHERE a.account_no = NEW."account_no"; | |
IF active_account != TRUE THEN |
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
version: '2' | |
services: | |
graphql-engine: | |
image: hasura/graphql-engine:latest | |
ports: | |
- '80:8080' | |
restart: always | |
environment: | |
HASURA_GRAPHQL_DATABASE_URL: postgres://<rds-user>:<rds-password>@<rds-instance>:5432/<rds-dbname> | |
HASURA_GRAPHQL_ACCESS_KEY: mylongsecretaccesskey |
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
mutation update_drafts { | |
update_article( | |
where: {author: {name: {_eq: "John"}}}, | |
_set: {is_published: true} | |
) { | |
affected_rows | |
} | |
} |
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
mutation update_likes { | |
update_article( | |
where: {id: {_eq: 1}}, | |
_inc: {likes: 1} | |
) { | |
affected_rows | |
returning { | |
id | |
likes | |
} |
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
mutation update_title_content { | |
update_article( | |
where: {id: {_eq: 1}}, | |
_set: { | |
title: "John's new first post title", | |
content: "New content for John's first post" | |
} | |
) { | |
affected_rows | |
returning { |
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
update_author( | |
_inc: author_inc_input | |
_set: author_set_input | |
where: author_bool_exp! | |
): author_mutation_response | |
author_set_input { | |
id: Int | |
name: String | |
} |
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 author ( | |
id INTEGER PRIMARY KEY, | |
name TEXT | |
); | |
CREATE TABLE article ( | |
id INTEGER PRIMARY KEY, | |
title TEXT, | |
content TEXT, | |
author_id INTEGER, |
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
{-# LANGUAGE GeneralizedNewtypeDeriving #-} | |
{-# LANGUAGE TemplateHaskell #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
module Main where | |
import Control.Applicative | |
import Control.Monad.Except | |
import Control.Monad.IO.Class () | |
import Control.Monad.Reader |
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
# -*- coding: utf8 -*- | |
# Some limey functions! | |
from functools import reduce | |
import itertools | |
import unittest | |
def omit(x, li): |