Browse Source

remove generated psql code from git.

master
Gisle Aune 3 years ago
parent
commit
21b7b44159
  1. 2
      .gitignore
  2. 139
      database/postgres/psqlcore/changes.sql.go
  3. 153
      database/postgres/psqlcore/channels.sql.go
  4. 177
      database/postgres/psqlcore/chapters.sql.go
  5. 235
      database/postgres/psqlcore/characters.sql.go
  6. 42
      database/postgres/psqlcore/counter.sql.go
  7. 29
      database/postgres/psqlcore/db.go
  8. 75
      database/postgres/psqlcore/models.go
  9. 201
      database/postgres/psqlcore/stories.sql.go
  10. 302
      database/postgres/psqlcore/tags.sql.go

2
.gitignore

@ -14,6 +14,8 @@ rpdata-*
/main.exe
/graph2/graphcore/*_gen.go
/database/postgres/psqlcore/*.go
!/database/postgres/psqlcore/package.go
generated.gql
generated.go
/dump.zip

139
database/postgres/psqlcore/changes.sql.go

@ -1,139 +0,0 @@
// Code generated by sqlc. DO NOT EDIT.
// source: changes.sql
package psqlcore
import (
"context"
"encoding/json"
"time"
"github.com/lib/pq"
)
const deleteChange = `-- name: DeleteChange :exec
DELETE FROM data_change WHERE id = $1
`
func (q *Queries) DeleteChange(ctx context.Context, id string) error {
_, err := q.db.ExecContext(ctx, deleteChange, id)
return err
}
const insertChange = `-- name: InsertChange :exec
INSERT INTO data_change (id, model, op, author, listed, date, keys, objects)
VALUES (
$1::text, $2::text, $3::text, $4::text,
$5::boolean, $6::timestamp, $7::text[],
$8::jsonb
)
`
type InsertChangeParams struct {
ID string `json:"id"`
Model string `json:"model"`
Op string `json:"op"`
Author string `json:"author"`
Listed bool `json:"listed"`
Date time.Time `json:"date"`
Keys []string `json:"keys"`
Objects json.RawMessage `json:"objects"`
}
func (q *Queries) InsertChange(ctx context.Context, arg InsertChangeParams) error {
_, err := q.db.ExecContext(ctx, insertChange,
arg.ID,
arg.Model,
arg.Op,
arg.Author,
arg.Listed,
arg.Date,
pq.Array(arg.Keys),
arg.Objects,
)
return err
}
const selectChangeByID = `-- name: SelectChangeByID :one
SELECT id, model, op, author, listed, date, keys, objects FROM data_change WHERE id = $1 LIMIT 1
`
func (q *Queries) SelectChangeByID(ctx context.Context, id string) (DataChange, error) {
row := q.db.QueryRowContext(ctx, selectChangeByID, id)
var i DataChange
err := row.Scan(
&i.ID,
&i.Model,
&i.Op,
&i.Author,
&i.Listed,
&i.Date,
pq.Array(&i.Keys),
&i.Objects,
)
return i, err
}
const selectChanges = `-- name: SelectChanges :many
SELECT id, model, op, author, listed, date, keys, objects FROM data_change
WHERE ($1::bool = false OR keys && ($2::text[]))
AND ($3::bool = false OR date >= $4::timestamp)
AND ($5::bool = false OR date <= $6::timestamp)
AND ($7::bool = false OR author = $8::text)
ORDER BY date DESC
LIMIT $9::int
`
type SelectChangesParams struct {
FilterKeys bool `json:"filter_keys"`
Keys []string `json:"keys"`
FilterEarliestDate bool `json:"filter_earliest_date"`
EarliestDate time.Time `json:"earliest_date"`
FilterLatestDate bool `json:"filter_latest_date"`
LatestDate time.Time `json:"latest_date"`
FilterAuthor bool `json:"filter_author"`
Author string `json:"author"`
LimitSize int32 `json:"limit_size"`
}
func (q *Queries) SelectChanges(ctx context.Context, arg SelectChangesParams) ([]DataChange, error) {
rows, err := q.db.QueryContext(ctx, selectChanges,
arg.FilterKeys,
pq.Array(arg.Keys),
arg.FilterEarliestDate,
arg.EarliestDate,
arg.FilterLatestDate,
arg.LatestDate,
arg.FilterAuthor,
arg.Author,
arg.LimitSize,
)
if err != nil {
return nil, err
}
defer rows.Close()
items := []DataChange{}
for rows.Next() {
var i DataChange
if err := rows.Scan(
&i.ID,
&i.Model,
&i.Op,
&i.Author,
&i.Listed,
&i.Date,
pq.Array(&i.Keys),
&i.Objects,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Close(); err != nil {
return nil, err
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}

153
database/postgres/psqlcore/channels.sql.go

@ -1,153 +0,0 @@
// Code generated by sqlc. DO NOT EDIT.
// source: channels.sql
package psqlcore
import (
"context"
"github.com/lib/pq"
)
const deleteChannel = `-- name: DeleteChannel :exec
DELETE FROM data_channel WHERE name=$1
`
func (q *Queries) DeleteChannel(ctx context.Context, name string) error {
_, err := q.db.ExecContext(ctx, deleteChannel, name)
return err
}
const insertChannel = `-- name: InsertChannel :exec
INSERT INTO data_channel (name, logged, hub, event_name, location_name)
VALUES (
$1::text,
$2::boolean, $3::boolean,
$4::text, $5::text
)
`
type InsertChannelParams struct {
Name string `json:"name"`
Logged bool `json:"logged"`
Hub bool `json:"hub"`
EventName string `json:"event_name"`
LocationName string `json:"location_name"`
}
func (q *Queries) InsertChannel(ctx context.Context, arg InsertChannelParams) error {
_, err := q.db.ExecContext(ctx, insertChannel,
arg.Name,
arg.Logged,
arg.Hub,
arg.EventName,
arg.LocationName,
)
return err
}
const selectChannelByName = `-- name: SelectChannelByName :one
SELECT name, logged, hub, event_name, location_name FROM data_channel WHERE name = $1 LIMIT 1
`
func (q *Queries) SelectChannelByName(ctx context.Context, name string) (DataChannel, error) {
row := q.db.QueryRowContext(ctx, selectChannelByName, name)
var i DataChannel
err := row.Scan(
&i.Name,
&i.Logged,
&i.Hub,
&i.EventName,
&i.LocationName,
)
return i, err
}
const selectChannels = `-- name: SelectChannels :many
SELECT name, logged, hub, event_name, location_name FROM data_channel
WHERE ($1::bool = false OR name = ANY($2::text[]))
AND ($3::bool = false OR logged = $4)
AND ($5::bool = false OR event_name = $6)
AND ($7::bool = false OR location_name = $8)
ORDER BY name
LIMIT $9::int
`
type SelectChannelsParams struct {
FilterName bool `json:"filter_name"`
Names []string `json:"names"`
FilterLogged bool `json:"filter_logged"`
Logged bool `json:"logged"`
FilterEventName bool `json:"filter_event_name"`
EventName string `json:"event_name"`
FilterLocationName bool `json:"filter_location_name"`
LocationName string `json:"location_name"`
LimitSize int32 `json:"limit_size"`
}
func (q *Queries) SelectChannels(ctx context.Context, arg SelectChannelsParams) ([]DataChannel, error) {
rows, err := q.db.QueryContext(ctx, selectChannels,
arg.FilterName,
pq.Array(arg.Names),
arg.FilterLogged,
arg.Logged,
arg.FilterEventName,
arg.EventName,
arg.FilterLocationName,
arg.LocationName,
arg.LimitSize,
)
if err != nil {
return nil, err
}
defer rows.Close()
items := []DataChannel{}
for rows.Next() {
var i DataChannel
if err := rows.Scan(
&i.Name,
&i.Logged,
&i.Hub,
&i.EventName,
&i.LocationName,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Close(); err != nil {
return nil, err
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const updateChannel = `-- name: UpdateChannel :exec
UPDATE data_channel
SET logged=$1::boolean,
hub=$2::boolean,
event_name=$3::text,
location_name=$4::text
WHERE name=$5::text
`
type UpdateChannelParams struct {
Logged bool `json:"logged"`
Hub bool `json:"hub"`
EventName string `json:"event_name"`
LocationName string `json:"location_name"`
Name string `json:"name"`
}
func (q *Queries) UpdateChannel(ctx context.Context, arg UpdateChannelParams) error {
_, err := q.db.ExecContext(ctx, updateChannel,
arg.Logged,
arg.Hub,
arg.EventName,
arg.LocationName,
arg.Name,
)
return err
}

177
database/postgres/psqlcore/chapters.sql.go

@ -1,177 +0,0 @@
// Code generated by sqlc. DO NOT EDIT.
// source: chapters.sql
package psqlcore
import (
"context"
"time"
)
const deleteChapter = `-- name: DeleteChapter :exec
DELETE FROM story_chapter WHERE id=$1
`
func (q *Queries) DeleteChapter(ctx context.Context, id string) error {
_, err := q.db.ExecContext(ctx, deleteChapter, id)
return err
}
const deleteChaptersByStoryID = `-- name: DeleteChaptersByStoryID :exec
DELETE FROM story_chapter WHERE story_id=$1
`
func (q *Queries) DeleteChaptersByStoryID(ctx context.Context, storyID string) error {
_, err := q.db.ExecContext(ctx, deleteChaptersByStoryID, storyID)
return err
}
const insertChapter = `-- name: InsertChapter :exec
INSERT INTO story_chapter (id, story_id, title, author, source, created_date, fictional_date, edited_date, comment_mode, comments_locked)
VALUES (
$1::TEXT, $2::TEXT, $3::TEXT, $4::TEXT, $5::TEXT,
$6::TIMESTAMP, $7::TIMESTAMP, $8::TIMESTAMP,
$9::TEXT, $10::BOOLEAN
)
`
type InsertChapterParams struct {
ID string `json:"id"`
StoryID string `json:"story_id"`
Title string `json:"title"`
Author string `json:"author"`
Source string `json:"source"`
CreatedDate time.Time `json:"created_date"`
FictionalDate time.Time `json:"fictional_date"`
EditedDate time.Time `json:"edited_date"`
CommentMode string `json:"comment_mode"`
CommentsLocked bool `json:"comments_locked"`
}
func (q *Queries) InsertChapter(ctx context.Context, arg InsertChapterParams) error {
_, err := q.db.ExecContext(ctx, insertChapter,
arg.ID,
arg.StoryID,
arg.Title,
arg.Author,
arg.Source,
arg.CreatedDate,
arg.FictionalDate,
arg.EditedDate,
arg.CommentMode,
arg.CommentsLocked,
)
return err
}
const selectChapter = `-- name: SelectChapter :one
SELECT id, story_id, title, author, source, created_date, fictional_date, edited_date, comment_mode, comments_locked FROM story_chapter WHERE id=$1::TEXT LIMIT 1
`
func (q *Queries) SelectChapter(ctx context.Context, dollar_1 string) (StoryChapter, error) {
row := q.db.QueryRowContext(ctx, selectChapter, dollar_1)
var i StoryChapter
err := row.Scan(
&i.ID,
&i.StoryID,
&i.Title,
&i.Author,
&i.Source,
&i.CreatedDate,
&i.FictionalDate,
&i.EditedDate,
&i.CommentMode,
&i.CommentsLocked,
)
return i, err
}
const selectChapters = `-- name: SelectChapters :many
SELECT id, story_id, title, author, source, created_date, fictional_date, edited_date, comment_mode, comments_locked FROM story_chapter WHERE (sqlx.arg(story_id)::TEXT == '' OR story_id=$1::TEXT) ORDER BY created_date LIMIT $2::INT
`
type SelectChaptersParams struct {
StoryID string `json:"story_id"`
LimitSize int32 `json:"limit_size"`
}
func (q *Queries) SelectChapters(ctx context.Context, arg SelectChaptersParams) ([]StoryChapter, error) {
rows, err := q.db.QueryContext(ctx, selectChapters, arg.StoryID, arg.LimitSize)
if err != nil {
return nil, err
}
defer rows.Close()
items := []StoryChapter{}
for rows.Next() {
var i StoryChapter
if err := rows.Scan(
&i.ID,
&i.StoryID,
&i.Title,
&i.Author,
&i.Source,
&i.CreatedDate,
&i.FictionalDate,
&i.EditedDate,
&i.CommentMode,
&i.CommentsLocked,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Close(); err != nil {
return nil, err
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const updateChapter = `-- name: UpdateChapter :exec
UPDATE story_chapter
SET title=$1,
source=$2,
fictional_date=$3,
comment_mode=$4,
comments_locked=$5
WHERE id=$6
`
type UpdateChapterParams struct {
Title string `json:"title"`
Source string `json:"source"`
FictionalDate time.Time `json:"fictional_date"`
CommentMode string `json:"comment_mode"`
CommentsLocked bool `json:"comments_locked"`
ID string `json:"id"`
}
func (q *Queries) UpdateChapter(ctx context.Context, arg UpdateChapterParams) error {
_, err := q.db.ExecContext(ctx, updateChapter,
arg.Title,
arg.Source,
arg.FictionalDate,
arg.CommentMode,
arg.CommentsLocked,
arg.ID,
)
return err
}
const updateChapterStoryID = `-- name: UpdateChapterStoryID :exec
UPDATE story_chapter
SET story_id=$1::TEXT
WHERE id=$2
`
type UpdateChapterStoryIDParams struct {
StoryID string `json:"story_id"`
ID string `json:"id"`
}
func (q *Queries) UpdateChapterStoryID(ctx context.Context, arg UpdateChapterStoryIDParams) error {
_, err := q.db.ExecContext(ctx, updateChapterStoryID, arg.StoryID, arg.ID)
return err
}

235
database/postgres/psqlcore/characters.sql.go

@ -1,235 +0,0 @@
// Code generated by sqlc. DO NOT EDIT.
// source: characters.sql
package psqlcore
import (
"context"
"github.com/lib/pq"
)
const addCharacterNick = `-- name: AddCharacterNick :exec
UPDATE data_character
SET nicks=append(nicks, $1::text)
WHERE id=$2::text
`
type AddCharacterNickParams struct {
Nick string `json:"nick"`
ID string `json:"id"`
}
func (q *Queries) AddCharacterNick(ctx context.Context, arg AddCharacterNickParams) error {
_, err := q.db.ExecContext(ctx, addCharacterNick, arg.Nick, arg.ID)
return err
}
const deleteCharacter = `-- name: DeleteCharacter :exec
DELETE FROM data_character WHERE id=$1
`
func (q *Queries) DeleteCharacter(ctx context.Context, id string) error {
_, err := q.db.ExecContext(ctx, deleteCharacter, id)
return err
}
const insertCharacter = `-- name: InsertCharacter :exec
INSERT INTO data_character (id, nicks, name, short_name, author, description, ts_vector) VALUES (
$1::text, $2::text[], $3::text,
$4::text, $5::text, $6::text,
to_tsvector(
'english',
$3::text || ' ' || $6::text || ' ' || $5::text || ' '
|| immutable_array_to_string(
$2::text[], ' '
)
)
)
`
type InsertCharacterParams struct {
ID string `json:"id"`
Nicks []string `json:"nicks"`
Name string `json:"name"`
ShortName string `json:"short_name"`
Author string `json:"author"`
Description string `json:"description"`
}
func (q *Queries) InsertCharacter(ctx context.Context, arg InsertCharacterParams) error {
_, err := q.db.ExecContext(ctx, insertCharacter,
arg.ID,
pq.Array(arg.Nicks),
arg.Name,
arg.ShortName,
arg.Author,
arg.Description,
)
return err
}
const removeCharacterNick = `-- name: RemoveCharacterNick :exec
UPDATE data_character
SET nicks=array_remove(nicks, $1::text)
WHERE id=$2::text
`
type RemoveCharacterNickParams struct {
Nick string `json:"nick"`
ID string `json:"id"`
}
func (q *Queries) RemoveCharacterNick(ctx context.Context, arg RemoveCharacterNickParams) error {
_, err := q.db.ExecContext(ctx, removeCharacterNick, arg.Nick, arg.ID)
return err
}
const selectCharacterByID = `-- name: SelectCharacterByID :one
SELECT id, nicks, name, short_name, author, description, ts_vector FROM data_character WHERE id = $1::text
`
func (q *Queries) SelectCharacterByID(ctx context.Context, id string) (DataCharacter, error) {
row := q.db.QueryRowContext(ctx, selectCharacterByID, id)
var i DataCharacter
err := row.Scan(
&i.ID,
pq.Array(&i.Nicks),
&i.Name,
&i.ShortName,
&i.Author,
&i.Description,
&i.TsVector,
)
return i, err
}
const selectCharacterByName = `-- name: SelectCharacterByName :one
SELECT id, nicks, name, short_name, author, description, ts_vector FROM data_character WHERE name = $1::text
`
func (q *Queries) SelectCharacterByName(ctx context.Context, name string) (DataCharacter, error) {
row := q.db.QueryRowContext(ctx, selectCharacterByName, name)
var i DataCharacter
err := row.Scan(
&i.ID,
pq.Array(&i.Nicks),
&i.Name,
&i.ShortName,
&i.Author,
&i.Description,
&i.TsVector,
)
return i, err
}
const selectCharacterByNick = `-- name: SelectCharacterByNick :one
SELECT id, nicks, name, short_name, author, description, ts_vector FROM data_character WHERE nicks <@ ARRAY[$1::text]
`
func (q *Queries) SelectCharacterByNick(ctx context.Context, nick string) (DataCharacter, error) {
row := q.db.QueryRowContext(ctx, selectCharacterByNick, nick)
var i DataCharacter
err := row.Scan(
&i.ID,
pq.Array(&i.Nicks),
&i.Name,
&i.ShortName,
&i.Author,
&i.Description,
&i.TsVector,
)
return i, err
}
const selectCharacters = `-- name: SelectCharacters :many
SELECT id, nicks, name, short_name, author, description, ts_vector FROM data_character
WHERE ($1::bool = false OR id = ANY($2::text[]))
AND ($3::bool = false OR name = ANY($4::text[]))
AND ($5::bool = false OR nicks && ($6::text[]))
AND ($7::bool = false OR author = $8::text)
AND ($9::bool = false OR "ts_vector" @@ to_tsquery($10::text))
LIMIT $11::int
`
type SelectCharactersParams struct {
FilterID bool `json:"filter_id"`
Ids []string `json:"ids"`
FilterName bool `json:"filter_name"`
Names []string `json:"names"`
FilterNick bool `json:"filter_nick"`
Nicks []string `json:"nicks"`
FilterAuthor bool `json:"filter_author"`
Author string `json:"author"`
FilterSearch bool `json:"filter_search"`
Search string `json:"search"`
LimitSize int32 `json:"limit_size"`
}
func (q *Queries) SelectCharacters(ctx context.Context, arg SelectCharactersParams) ([]DataCharacter, error) {
rows, err := q.db.QueryContext(ctx, selectCharacters,
arg.FilterID,
pq.Array(arg.Ids),
arg.FilterName,
pq.Array(arg.Names),
arg.FilterNick,
pq.Array(arg.Nicks),
arg.FilterAuthor,
arg.Author,
arg.FilterSearch,
arg.Search,
arg.LimitSize,
)
if err != nil {
return nil, err
}
defer rows.Close()
items := []DataCharacter{}
for rows.Next() {
var i DataCharacter
if err := rows.Scan(
&i.ID,
pq.Array(&i.Nicks),
&i.Name,
&i.ShortName,
&i.Author,
&i.Description,
&i.TsVector,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Close(); err != nil {
return nil, err
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const updateCharacter = `-- name: UpdateCharacter :exec
UPDATE data_character
SET name=$1::text,
short_name=$2::text,
description=$3::text
WHERE id=$4::text
`
type UpdateCharacterParams struct {
Name string `json:"name"`
ShortName string `json:"short_name"`
Description string `json:"description"`
ID string `json:"id"`
}
func (q *Queries) UpdateCharacter(ctx context.Context, arg UpdateCharacterParams) error {
_, err := q.db.ExecContext(ctx, updateCharacter,
arg.Name,
arg.ShortName,
arg.Description,
arg.ID,
)
return err
}

42
database/postgres/psqlcore/counter.sql.go

@ -1,42 +0,0 @@
// Code generated by sqlc. DO NOT EDIT.
// source: counter.sql
package psqlcore
import (
"context"
)
const bumpCounter = `-- name: BumpCounter :exec
UPDATE core_counter SET value = value + 1 WHERE id = $1::text AND value <= $2::int
`
type BumpCounterParams struct {
ID string `json:"id"`
Value int32 `json:"value"`
}
func (q *Queries) BumpCounter(ctx context.Context, arg BumpCounterParams) error {
_, err := q.db.ExecContext(ctx, bumpCounter, arg.ID, arg.Value)
return err
}
const ensureCounter = `-- name: EnsureCounter :exec
INSERT INTO core_counter (id, value) VALUES ($1::text, 0) ON CONFLICT DO NOTHING
`
func (q *Queries) EnsureCounter(ctx context.Context, dollar_1 string) error {
_, err := q.db.ExecContext(ctx, ensureCounter, dollar_1)
return err
}
const incrementCounter = `-- name: IncrementCounter :one
UPDATE core_counter SET value = value + 1 WHERE id = $1::text RETURNING value::int
`
func (q *Queries) IncrementCounter(ctx context.Context, dollar_1 string) (int32, error) {
row := q.db.QueryRowContext(ctx, incrementCounter, dollar_1)
var value int32
err := row.Scan(&value)
return value, err
}

29
database/postgres/psqlcore/db.go

@ -1,29 +0,0 @@
// Code generated by sqlc. DO NOT EDIT.
package psqlcore
import (
"context"
"database/sql"
)
type DBTX interface {
ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
PrepareContext(context.Context, string) (*sql.Stmt, error)
QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
QueryRowContext(context.Context, string, ...interface{}) *sql.Row
}
func New(db DBTX) *Queries {
return &Queries{db: db}
}
type Queries struct {
db DBTX
}
func (q *Queries) WithTx(tx *sql.Tx) *Queries {
return &Queries{
db: tx,
}
}

75
database/postgres/psqlcore/models.go

@ -1,75 +0,0 @@
// Code generated by sqlc. DO NOT EDIT.
package psqlcore
import (
"database/sql"
"encoding/json"
"time"
)
type CommonTag struct {
Tag string `json:"tag"`
TargetKind string `json:"target_kind"`
TargetID string `json:"target_id"`
}
type CoreCounter struct {
ID string `json:"id"`
Value sql.NullInt32 `json:"value"`
}
type DataChange struct {
ID string `json:"id"`
Model string `json:"model"`
Op string `json:"op"`
Author string `json:"author"`
Listed bool `json:"listed"`
Date time.Time `json:"date"`
Keys []string `json:"keys"`
Objects json.RawMessage `json:"objects"`
}
type DataChannel struct {
Name string `json:"name"`
Logged bool `json:"logged"`
Hub bool `json:"hub"`
EventName string `json:"event_name"`
LocationName string `json:"location_name"`
}
type DataCharacter struct {
ID string `json:"id"`
Nicks []string `json:"nicks"`
Name string `json:"name"`
ShortName string `json:"short_name"`
Author string `json:"author"`
Description string `json:"description"`
TsVector interface{} `json:"ts_vector"`
}
type Story struct {
ID string `json:"id"`
Author string `json:"author"`
Name string `json:"name"`
Category string `json:"category"`
Open bool `json:"open"`
Listed bool `json:"listed"`
SortByFictionalDate bool `json:"sort_by_fictional_date"`
CreatedDate time.Time `json:"created_date"`
FictionalDate time.Time `json:"fictional_date"`
UpdatedDate time.Time `json:"updated_date"`
}
type StoryChapter struct {
ID string `json:"id"`
StoryID string `json:"story_id"`
Title string `json:"title"`
Author string `json:"author"`
Source string `json:"source"`
CreatedDate time.Time `json:"created_date"`
FictionalDate time.Time `json:"fictional_date"`
EditedDate time.Time `json:"edited_date"`
CommentMode string `json:"comment_mode"`
CommentsLocked bool `json:"comments_locked"`
}

201
database/postgres/psqlcore/stories.sql.go

@ -1,201 +0,0 @@
// Code generated by sqlc. DO NOT EDIT.
// source: stories.sql
package psqlcore
import (
"context"
"time"
"github.com/lib/pq"
)
const deleteStory = `-- name: DeleteStory :exec
DELETE FROM story WHERE id=$1
`
func (q *Queries) DeleteStory(ctx context.Context, id string) error {
_, err := q.db.ExecContext(ctx, deleteStory, id)
return err
}
const insertStory = `-- name: InsertStory :exec
INSERT INTO story (id, author, name, category, open, listed, sort_by_fictional_date, created_date, fictional_date, updated_date)
VALUES (
$1::text, $2::text, $3::text, $4::text,
$5::boolean, $6::boolean, $7::boolean,
$8::timestamp, $9::timestamp, $10::timestamp
)
`
type InsertStoryParams struct {
ID string `json:"id"`
Author string `json:"author"`
Name string `json:"name"`
Category string `json:"category"`
Open bool `json:"open"`
Listed bool `json:"listed"`
SortByFictionalDate bool `json:"sort_by_fictional_date"`
CreatedDate time.Time `json:"created_date"`
FictionalDate time.Time `json:"fictional_date"`
UpdatedDate time.Time `json:"updated_date"`
}
func (q *Queries) InsertStory(ctx context.Context, arg InsertStoryParams) error {
_, err := q.db.ExecContext(ctx, insertStory,
arg.ID,
arg.Author,
arg.Name,
arg.Category,
arg.Open,
arg.Listed,
arg.SortByFictionalDate,
arg.CreatedDate,
arg.FictionalDate,
arg.UpdatedDate,
)
return err
}
const selectStories = `-- name: SelectStories :many
SELECT id, author, name, category, open, listed, sort_by_fictional_date, created_date, fictional_date, updated_date FROM story
WHERE ($1::bool = false OR id = ANY($2::text[]))
AND ($3::bool = false OR name = $4::text)
AND ($5::bool = false OR fictional_date >= $6::timestamp)
AND ($7::bool = false OR fictional_date <= $8::timestamp)
AND ($9::bool = false OR category = $10::text)
AND ($11::bool = false OR open = $12::bool)
AND ($13::bool = false OR unlisted = $14::bool)
ORDER BY updated_date
LIMIT $15::int
`
type SelectStoriesParams struct {
FilterID bool `json:"filter_id"`
Ids []string `json:"ids"`
FilterAuthor bool `json:"filter_author"`
Author string `json:"author"`
FilterEarlistFictionalDate bool `json:"filter_earlist_fictional_date"`
EarliestFictionalDate time.Time `json:"earliest_fictional_date"`
FilterLastestFictionalDate bool `json:"filter_lastest_fictional_date"`
LatestFictionalDate time.Time `json:"latest_fictional_date"`
FilterCategory bool `json:"filter_category"`
Category string `json:"category"`
FilterOpen bool `json:"filter_open"`
Open bool `json:"open"`
FilterUnlisted bool `json:"filter_unlisted"`
Unlisted bool `json:"unlisted"`
LimitSize int32 `json:"limit_size"`
}
func (q *Queries) SelectStories(ctx context.Context, arg SelectStoriesParams) ([]Story, error) {
rows, err := q.db.QueryContext(ctx, selectStories,
arg.FilterID,
pq.Array(arg.Ids),
arg.FilterAuthor,
arg.Author,
arg.FilterEarlistFictionalDate,
arg.EarliestFictionalDate,
arg.FilterLastestFictionalDate,
arg.LatestFictionalDate,
arg.FilterCategory,
arg.Category,
arg.FilterOpen,
arg.Open,
arg.FilterUnlisted,
arg.Unlisted,
arg.LimitSize,
)
if err != nil {
return nil, err
}
defer rows.Close()
items := []Story{}
for rows.Next() {
var i Story
if err := rows.Scan(
&i.ID,
&i.Author,
&i.Name,
&i.Category,
&i.Open,
&i.Listed,
&i.SortByFictionalDate,
&i.CreatedDate,
&i.FictionalDate,
&i.UpdatedDate,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Close(); err != nil {
return nil, err
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const selectStory = `-- name: SelectStory :one
SELECT id, author, name, category, open, listed, sort_by_fictional_date, created_date, fictional_date, updated_date FROM story WHERE id = $1 LIMIT 1
`
func (q *Queries) SelectStory(ctx context.Context, id string) (Story, error) {
row := q.db.QueryRowContext(ctx, selectStory, id)
var i Story
err := row.Scan(
&i.ID,
&i.Author,
&i.Name,
&i.Category,
&i.Open,
&i.Listed,
&i.SortByFictionalDate,
&i.CreatedDate,
&i.FictionalDate,
&i.UpdatedDate,
)
return i, err
}
const updateStory = `-- name: UpdateStory :exec
UPDATE story
SET name=$1,
category=$2,
author=$3,
open=$4,
listed=$5,
fictional_date=$6,
updated_date=$7,
sort_by_fictional_date=$8
WHERE id=$9
`
type UpdateStoryParams struct {
Name string `json:"name"`
Category string `json:"category"`
Author string `json:"author"`
Open bool `json:"open"`
Listed bool `json:"listed"`
FictionalDate time.Time `json:"fictional_date"`
UpdatedDate time.Time `json:"updated_date"`
SortByFictionalDate bool `json:"sort_by_fictional_date"`
ID string `json:"id"`
}
func (q *Queries) UpdateStory(ctx context.Context, arg UpdateStoryParams) error {
_, err := q.db.ExecContext(ctx, updateStory,
arg.Name,
arg.Category,
arg.Author,
arg.Open,
arg.Listed,
arg.FictionalDate,
arg.UpdatedDate,
arg.SortByFictionalDate,
arg.ID,
)
return err
}

302
database/postgres/psqlcore/tags.sql.go

@ -1,302 +0,0 @@
// Code generated by sqlc. DO NOT EDIT.
// source: tags.sql
package psqlcore
import (
"context"
"github.com/lib/pq"
)
const clearTag = `-- name: ClearTag :exec
DELETE FROM common_tag
WHERE tag=$1::TEXT
AND target_kind=$2::TEXT
AND target_id=$3::TEXT
`
type ClearTagParams struct {
Tag string `json:"tag"`
TargetKind string `json:"target_kind"`
TargetID string `json:"target_id"`
}
func (q *Queries) ClearTag(ctx context.Context, arg ClearTagParams) error {
_, err := q.db.ExecContext(ctx, clearTag, arg.Tag, arg.TargetKind, arg.TargetID)
return err
}
const clearTagsByTarget = `-- name: ClearTagsByTarget :exec
DELETE FROM common_tag
WHERE target_kind=$1::TEXT
AND target_id=$2::TEXT
`
type ClearTagsByTargetParams struct {
TargetKind string `json:"target_kind"`
TargetID string `json:"target_id"`
}
func (q *Queries) ClearTagsByTarget(ctx context.Context, arg ClearTagsByTargetParams) error {
_, err := q.db.ExecContext(ctx, clearTagsByTarget, arg.TargetKind, arg.TargetID)
return err
}
const clearTagsByTargetLike = `-- name: ClearTagsByTargetLike :exec
DELETE FROM common_tag
WHERE target_kind=$1::TEXT
AND target_id=$2::TEXT
AND tag LIKE $3::TEXT
`
type ClearTagsByTargetLikeParams struct {
TargetKind string `json:"target_kind"`
TargetID string `json:"target_id"`
TagLike string `json:"tag_like"`
}
func (q *Queries) ClearTagsByTargetLike(ctx context.Context, arg ClearTagsByTargetLikeParams) error {
_, err := q.db.ExecContext(ctx, clearTagsByTargetLike, arg.TargetKind, arg.TargetID, arg.TagLike)
return err
}
const selectDistinctTags = `-- name: SelectDistinctTags :many
SELECT DISTINCT tag FROM common_tag ORDER BY tag
`
func (q *Queries) SelectDistinctTags(ctx context.Context) ([]string, error) {
rows, err := q.db.QueryContext(ctx, selectDistinctTags)
if err != nil {
return nil, err
}
defer rows.Close()
items := []string{}
for rows.Next() {
var tag string
if err := rows.Scan(&tag); err != nil {
return nil, err
}
items = append(items, tag)
}
if err := rows.Close(); err != nil {
return nil, err
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const selectDistinctTagsLike = `-- name: SelectDistinctTagsLike :many
SELECT DISTINCT tag FROM common_tag WHERE tag LIKE $1::text ORDER BY tag
`
func (q *Queries) SelectDistinctTagsLike(ctx context.Context, dollar_1 string) ([]string, error) {
rows, err := q.db.QueryContext(ctx, selectDistinctTagsLike, dollar_1)
if err != nil {
return nil, err
}
defer rows.Close()
items := []string{}
for rows.Next() {
var tag string
if err := rows.Scan(&tag); err != nil {
return nil, err
}
items = append(items, tag)
}
if err := rows.Close(); err != nil {
return nil, err
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const selectTagsByTag = `-- name: SelectTagsByTag :many
SELECT tag, target_kind, target_id FROM common_tag WHERE tag = $1::text ORDER BY tag
`
func (q *Queries) SelectTagsByTag(ctx context.Context, tagName string) ([]CommonTag, error) {
rows, err := q.db.QueryContext(ctx, selectTagsByTag, tagName)
if err != nil {
return nil, err
}
defer rows.Close()
items := []CommonTag{}
for rows.Next() {
var i CommonTag
if err := rows.Scan(&i.Tag, &i.TargetKind, &i.TargetID); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Close(); err != nil {
return nil, err
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const selectTagsByTags = `-- name: SelectTagsByTags :many
SELECT tag, target_kind, target_id FROM common_tag WHERE tag = ANY($1::text[]) ORDER BY tag
`
func (q *Queries) SelectTagsByTags(ctx context.Context, tagNames []string) ([]CommonTag, error) {
rows, err := q.db.QueryContext(ctx, selectTagsByTags, pq.Array(tagNames))
if err != nil {
return nil, err
}
defer rows.Close()
items := []CommonTag{}
for rows.Next() {
var i CommonTag
if err := rows.Scan(&i.Tag, &i.TargetKind, &i.TargetID); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Close(); err != nil {
return nil, err
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const selectTagsByTarget = `-- name: SelectTagsByTarget :many
SELECT tag, target_kind, target_id FROM common_tag WHERE target_kind = $1 AND target_id = $2::text ORDER BY tag
`
type SelectTagsByTargetParams struct {
TargetKind string `json:"target_kind"`
TargetID string `json:"target_id"`
}
func (q *Queries) SelectTagsByTarget(ctx context.Context, arg SelectTagsByTargetParams) ([]CommonTag, error) {
rows, err := q.db.QueryContext(ctx, selectTagsByTarget, arg.TargetKind, arg.TargetID)
if err != nil {
return nil, err
}
defer rows.Close()
items := []CommonTag{}
for rows.Next() {
var i CommonTag
if err := rows.Scan(&i.Tag, &i.TargetKind, &i.TargetID); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Close(); err != nil {
return nil, err
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const selectTagsByTargets = `-- name: SelectTagsByTargets :many
SELECT tag, target_kind, target_id FROM common_tag WHERE target_kind = $1 AND target_id = ANY($2::text[]) ORDER BY tag
`
type SelectTagsByTargetsParams struct {
TargetKind string `json:"target_kind"`
TargetIds []string `json:"target_ids"`
}
func (q *Queries) SelectTagsByTargets(ctx context.Context, arg SelectTagsByTargetsParams) ([]CommonTag, error) {
rows, err := q.db.QueryContext(ctx, selectTagsByTargets, arg.TargetKind, pq.Array(arg.TargetIds))
if err != nil {
return nil, err
}
defer rows.Close()
items := []CommonTag{}
for rows.Next() {
var i CommonTag
if err := rows.Scan(&i.Tag, &i.TargetKind, &i.TargetID); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Close(); err != nil {
return nil, err
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const selectTargetsByTags = `-- name: SelectTargetsByTags :many
SELECT DISTINCT(target_id) FROM common_tag WHERE tag = ANY($1::text[]) AND target_kind = $2::text ORDER BY tag
`
type SelectTargetsByTagsParams struct {
TagNames []string `json:"tag_names"`
TargetKind string `json:"target_kind"`
}
func (q *Queries) SelectTargetsByTags(ctx context.Context, arg SelectTargetsByTagsParams) ([]string, error) {
rows, err := q.db.QueryContext(ctx, selectTargetsByTags, pq.Array(arg.TagNames), arg.TargetKind)
if err != nil {
return nil, err
}
defer rows.Close()
items := []string{}
for rows.Next() {
var target_id string
if err := rows.Scan(&target_id); err != nil {
return nil, err
}
items = append(items, target_id)
}
if err := rows.Close(); err != nil {
return nil, err
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const setTag = `-- name: SetTag :exec
INSERT INTO common_tag (tag, target_kind, target_id)
VALUES (
$1::TEXT, $2::TEXT, $3::TEXT
)
ON CONFLICT DO NOTHING
`
type SetTagParams struct {
Tag string `json:"tag"`
TargetKind string `json:"target_kind"`
TargetID string `json:"target_id"`
}
func (q *Queries) SetTag(ctx context.Context, arg SetTagParams) error {
_, err := q.db.ExecContext(ctx, setTag, arg.Tag, arg.TargetKind, arg.TargetID)
return err
}
const setTags = `-- name: SetTags :exec
INSERT INTO common_tag (tag, target_kind, target_id)
SELECT unnest($1::TEXT[]), $2::TEXT as target_kind, $3::TEXT as target_id
ON CONFLICT DO NOTHING
`
type SetTagsParams struct {
Tags []string `json:"tags"`
TargetKind string `json:"target_kind"`
TargetID string `json:"target_id"`
}
func (q *Queries) SetTags(ctx context.Context, arg SetTagsParams) error {
_, err := q.db.ExecContext(ctx, setTags, pq.Array(arg.Tags), arg.TargetKind, arg.TargetID)
return err
}
Loading…
Cancel
Save