You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
113 lines
3.1 KiB
113 lines
3.1 KiB
// Code generated by sqlc. DO NOT EDIT.
|
|
// source: stories.sql
|
|
|
|
package psqlcore
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/lib/pq"
|
|
)
|
|
|
|
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)
|
|
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
|
|
}
|