Skip to content

Instantly share code, notes, and snippets.

@tggreene
Last active November 3, 2019 19:25
Show Gist options
  • Save tggreene/bc9c964c18492e5959de96472f611a9b to your computer and use it in GitHub Desktop.
Save tggreene/bc9c964c18492e5959de96472f611a9b to your computer and use it in GitHub Desktop.
yas-snippets for hugsql
# -*- mode: snippet -*-
# name: hugsql-create-table
# key: create-table
# --
-- :name create-$1-table
-- :command :execute
-- :return :raw
create table if not exists $1 (
$2
);
# -*- mode: snippet -*-
# name: hugsql-insert
# key: insert
# --
-- :name $1
-- :command ${2:$$(yas-choose-value '(":insert" ":returning-execute"))}
-- :result ${3:$$(yas-choose-value '(":one" ":many" ":affected" ":raw"))}
insert into $4 ($5)
values (${5:$(mapconcat (function
(lambda (x)
(concat ":" x)))
(split-string yas-text ", ")
", ")});
# -*- mode: snippet -*-
# name: hugsql-query
# key: query
# --
-- :name $1
-- :command :query
-- :result ${2:$$(yas-choose-value '(":many" ":one"))}
select *
from $3;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment