-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3c858b5
commit 817e170
Showing
13 changed files
with
644 additions
and
7 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
examples/library/internal/gen | ||
tmp | ||
|
||
# Binaries for programs and plugins | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
services: | ||
exampledb: | ||
image: postgres | ||
ports: | ||
- 5432:5432 | ||
environment: | ||
- POSTGRES_PASSWORD=examplepassword | ||
- POSTGRES_USER=exampleuser | ||
- POSTGRES_DB=exampledb |
30 changes: 30 additions & 0 deletions
30
examples/library/internal/gen/pb/sqlc/examples/library/v1/author.sql
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
-- Code generated by protoc-gen-sqlc. DO NOT EDIT. | ||
-- source: | ||
-- examples/library/v1/author.proto | ||
-- | ||
-- name: GetAuthor :one | ||
SELECT * FROM Author | ||
WHERE author_id = $1 LIMIT 1; | ||
|
||
-- name: ListAuthor :many | ||
SELECT * FROM Author | ||
ORDER BY author_id; | ||
|
||
-- name: CreateAuthor :one | ||
INSERT INTO Author ( | ||
author_id, name, biography | ||
) VALUES ( | ||
$1, $2, $3 | ||
) | ||
RETURNING *; | ||
|
||
-- name: UpdateAuthor :one | ||
UPDATE Author SET | ||
name = $2, | ||
biography = $3 | ||
WHERE author_id = $1 | ||
RETURNING *; | ||
|
||
-- name: DeleteAuthor :exec | ||
DELETE FROM Author | ||
WHERE author_id = $1; |
37 changes: 37 additions & 0 deletions
37
examples/library/internal/gen/pb/sqlc/examples/library/v1/book.sql
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
-- Code generated by protoc-gen-sqlc. DO NOT EDIT. | ||
-- source: | ||
-- examples/library/v1/book.proto | ||
-- | ||
-- name: GetBook :one | ||
SELECT * FROM Book | ||
WHERE book_id = $1 LIMIT 1; | ||
|
||
-- name: ListBook :many | ||
SELECT * FROM Book | ||
ORDER BY book_id; | ||
|
||
-- name: CreateBook :one | ||
INSERT INTO Book ( | ||
book_id, author_id, isbn, book_type, title, year, available_time, tags, published, price | ||
) VALUES ( | ||
$1, $2, $3, $4, $5, $6, $7, $8, $9, $10 | ||
) | ||
RETURNING *; | ||
|
||
-- name: UpdateBook :one | ||
UPDATE Book SET | ||
author_id = $2, | ||
isbn = $3, | ||
book_type = $4, | ||
title = $5, | ||
year = $6, | ||
available_time = $7, | ||
tags = $8, | ||
published = $9, | ||
price = $10 | ||
WHERE book_id = $1 | ||
RETURNING *; | ||
|
||
-- name: DeleteBook :exec | ||
DELETE FROM Book | ||
WHERE book_id = $1; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
-- Code generated by protoc-gen-sqlc. DO NOT EDIT. | ||
-- source: | ||
-- | ||
|
||
CREATE TYPE BookType AS ENUM ( | ||
'BOOK_TYPE_UNSPECIFIED', | ||
'BOOK_TYPE_FICTION', | ||
'BOOK_TYPE_NONFICTION' | ||
); | ||
|
||
CREATE TABLE Author ( | ||
author_id INTEGER NOT NULL, | ||
name TEXT NOT NULL DEFAULT 'Anonymous', | ||
biography JSONB, | ||
PRIMARY KEY(author_id) | ||
); | ||
|
||
CREATE TABLE Book ( | ||
book_id INTEGER NOT NULL, | ||
author_id INTEGER NOT NULL, | ||
isbn TEXT NOT NULL, | ||
book_type BookType NOT NULL DEFAULT 'BOOK_TYPE_FICTION', | ||
title TEXT NOT NULL DEFAULT 'Unknown', | ||
year INTEGER NOT NULL DEFAULT 2000, | ||
available_time TIMESTAMP NOT NULL DEFAULT 'NOW()', | ||
tags TEXT[] NOT NULL DEFAULT '{}', | ||
published BOOLEAN DEFAULT false, | ||
price FLOAT, | ||
PRIMARY KEY(book_id), | ||
FOREIGN KEY(author_id) REFERENCES Author(author_id) ON DELETE CASCADE, | ||
UNIQUE(isbn) | ||
); | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.