Last active
November 3, 2019 19:25
-
-
Save tggreene/bc9c964c18492e5959de96472f611a9b to your computer and use it in GitHub Desktop.
yas-snippets for hugsql
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
# -*- mode: snippet -*- | |
# name: hugsql-create-table | |
# key: create-table | |
# -- | |
-- :name create-$1-table | |
-- :command :execute | |
-- :return :raw | |
create table if not exists $1 ( | |
$2 | |
); |
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
# -*- 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 ", ") | |
", ")}); |
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
# -*- 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