Documentation
¶
Index ¶
- func IntConvert[From, To ...](src From) To
- func IntPtrConvert[From, To ~int | ~int32 | ~int64 | ~float32 | ~float64](src *From) *To
- func NullBoolToPtr(n sql.NullBool) *bool
- func NullBytesToPtr(b []byte) *[]byte
- func NullFloat64ToPtr(n sql.NullFloat64) *float64
- func NullInt32ToPtr(n sql.NullInt32) *int32
- func NullInt64ToPtr(n sql.NullInt64) *int64
- func NullStringToPtr(n sql.NullString) *string
- func NullTimeToProto(n sql.NullTime) *timestamppb.Timestamp
- func OptionalWithFallback[T any](val *T, fallback T) T
- func ProtoToNullTime(t *timestamppb.Timestamp) sql.NullTime
- func ProtoToTime(t *timestamppb.Timestamp) time.Time
- func PtrBytesToNullString(p *[]byte) sql.NullString
- func PtrToNullBool(p *bool) sql.NullBool
- func PtrToNullBytes(b *[]byte) []byte
- func PtrToNullFloat64(p *float64) sql.NullFloat64
- func PtrToNullInt32(p *int32) sql.NullInt32
- func PtrToNullInt64(p *int64) sql.NullInt64
- func PtrToNullString(p *string) sql.NullString
- func SQLiteBoolPtrToInt64Ptr(b *bool) *int64
- func SQLiteBoolToInt(b bool) int64
- func SQLiteInt64PtrToBoolPtr(i *int64) *bool
- func SQLiteIntToBool(i int64) bool
- func TimeToProto(t time.Time) *timestamppb.Timestamp
- type Article
- type CreateArticleParams
- type DBTX
- type ListArticleByAuthorParams
- type ListArticleFilterByAuthorIsFeaturedPublishedAtTitleParams
- type ListArticleFilterByAuthorIsFeaturedPublishedAtTitleRow
- type Queries
- func (q *Queries) CreateArticle(ctx context.Context, arg CreateArticleParams) (string, error)
- func (q *Queries) DeleteArticle(ctx context.Context, id string) error
- func (q *Queries) GetArticleById(ctx context.Context, id string) (*Article, error)
- func (q *Queries) GetArticleBySlug(ctx context.Context, slug string) (*Article, error)
- func (q *Queries) ListAllArticle(ctx context.Context) ([]*Article, error)
- func (q *Queries) ListArticleByAuthor(ctx context.Context, arg ListArticleByAuthorParams) ([]*Article, error)
- func (q *Queries) ListArticleFilterByAuthorIsFeaturedPublishedAtTitle(ctx context.Context, ...) ([]*Article, int64, error)
- func (q *Queries) UpdateArticle(ctx context.Context, arg UpdateArticleParams) (*Article, error)
- func (q *Queries) WithTx(tx *sql.Tx) *Queries
- type UpdateArticleParams
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IntConvert ¶
func IntPtrConvert ¶
example: IntPtrConvert[int64, int32](dbRow.Age)
func NullBoolToPtr ¶
func NullFloat64ToPtr ¶
func NullFloat64ToPtr(n sql.NullFloat64) *float64
func NullInt32ToPtr ¶
--- Nullable SQL Type Converters ---
func NullInt64ToPtr ¶
func NullStringToPtr ¶
func NullStringToPtr(n sql.NullString) *string
func NullTimeToProto ¶
func NullTimeToProto(n sql.NullTime) *timestamppb.Timestamp
--- Time Converters ---
func OptionalWithFallback ¶
func OptionalWithFallback[T any](val *T, fallback T) T
OptionalWithFallback chooses fallback if optional value is nil
func ProtoToNullTime ¶
func ProtoToNullTime(t *timestamppb.Timestamp) sql.NullTime
func ProtoToTime ¶
func ProtoToTime(t *timestamppb.Timestamp) time.Time
A nil pointer returns a zero time.Time{}
func PtrBytesToNullString ¶
func PtrBytesToNullString(p *[]byte) sql.NullString
PtrBytesToNullString converts *[]byte to sql.NullString for MySQL compatibility
func PtrToNullBool ¶
func PtrToNullBytes ¶
func PtrToNullFloat64 ¶
func PtrToNullFloat64(p *float64) sql.NullFloat64
func PtrToNullInt32 ¶
func PtrToNullInt64 ¶
func PtrToNullString ¶
func PtrToNullString(p *string) sql.NullString
func SQLiteBoolPtrToInt64Ptr ¶
SQLiteBoolPtrToInt64Ptr converts *bool to *int64 for nullable columns via sqlc.narg
func SQLiteBoolToInt ¶
func SQLiteInt64PtrToBoolPtr ¶
SQLiteInt64PtrToBoolPtr is the inverse of SQLiteBoolPtrToInt64Ptr.
func TimeToProto ¶
func TimeToProto(t time.Time) *timestamppb.Timestamp
TimeToProto converts time.Time to timestamppb.Timestamp pointer
Types ¶
type Article ¶
type Article struct {
ID string `json:"id"`
Slug string `json:"slug"`
Title string `json:"title"`
Author string `json:"author"`
Subtitle *string `json:"subtitle"`
ReadingMinutes *int32 `json:"reading_minutes"`
LastViewedMs *int64 `json:"last_viewed_ms"`
Rating *float64 `json:"rating"`
CoverImage *[]byte `json:"cover_image"`
PublishedAt *time.Time `json:"published_at"`
Metadata *string `json:"metadata"`
IsFeatured bool `json:"is_featured"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
func ArticleFromSQL ¶
func (*Article) ArticleToSQL ¶
type CreateArticleParams ¶
type CreateArticleParams struct {
Slug string `json:"slug"`
Title string `json:"title"`
Author string `json:"author"`
Subtitle *string `json:"subtitle"`
ReadingMinutes *int32 `json:"reading_minutes"`
LastViewedMs *int64 `json:"last_viewed_ms"`
Rating *float64 `json:"rating"`
CoverImage *[]byte `json:"cover_image"`
PublishedAt *time.Time `json:"published_at"`
Metadata *string `json:"metadata"`
IsFeatured *bool `json:"is_featured"`
}
type ListArticleByAuthorParams ¶ added in v0.0.4
type ListArticleFilterByAuthorIsFeaturedPublishedAtTitleParams ¶
type ListArticleFilterByAuthorIsFeaturedPublishedAtTitleParams struct {
Author string `json:"author"`
IsFeatured bool `json:"is_featured"`
MinPublishedAt *time.Time `json:"min_published_at"`
MaxPublishedAt *time.Time `json:"max_published_at"`
Title string `json:"title"`
Offset int32 `json:"offset"`
Limit int32 `json:"limit"`
}
type ListArticleFilterByAuthorIsFeaturedPublishedAtTitleRow ¶ added in v0.0.5
type ListArticleFilterByAuthorIsFeaturedPublishedAtTitleRow = internal.ListArticleFilterByAuthorIsFeaturedPublishedAtTitleRow
type Queries ¶
func (*Queries) CreateArticle ¶
func (*Queries) DeleteArticle ¶
func (*Queries) GetArticleById ¶ added in v0.0.6
func (*Queries) GetArticleBySlug ¶
func (*Queries) ListAllArticle ¶
func (*Queries) ListArticleByAuthor ¶
func (*Queries) ListArticleFilterByAuthorIsFeaturedPublishedAtTitle ¶
func (*Queries) UpdateArticle ¶
type UpdateArticleParams ¶
type UpdateArticleParams struct {
Slug string `json:"slug"`
Title string `json:"title"`
Author string `json:"author"`
Subtitle *string `json:"subtitle"`
ReadingMinutes *int32 `json:"reading_minutes"`
LastViewedMs *int64 `json:"last_viewed_ms"`
Rating *float64 `json:"rating"`
CoverImage *[]byte `json:"cover_image"`
PublishedAt *time.Time `json:"published_at"`
Metadata *string `json:"metadata"`
IsFeatured *bool `json:"is_featured"`
}
Click to show internal directories.
Click to hide internal directories.