models

package
v0.0.0-...-8cc97d5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const PostTableName = "posts"

PostTableName is the database table name.

View Source
const PostTagTableName = "post_tags"

PostTagTableName is the database table name.

View Source
const TagTableName = "tags"

TagTableName is the database table name.

View Source
const UserTableName = "users"

UserTableName is the database table name.

Variables

View Source
var PostColumns = struct {
	ID          string
	AuthorID    string
	Title       string
	Body        string
	Status      string
	CreatedAt   string
	PublishedAt string
}{
	ID:          "id",
	AuthorID:    "author_id",
	Title:       "title",
	Body:        "body",
	Status:      "status",
	CreatedAt:   "created_at",
	PublishedAt: "published_at",
}

PostColumns contains all column names for the posts table.

View Source
var PostPreloadUser = sqlgen.PreloadDef{
	Name:     "User",
	Table:    UserTableName,
	JoinCond: "\"users\".\"id\" = \"posts\".\"author_id\"",
	Columns: []string{
		"\"users\".\"id\"",
		"\"users\".\"email\"",
		"\"users\".\"name\"",
		"\"users\".\"bio\"",
		"\"users\".\"created_at\"",
	},
}

PostPreloadUser is the PreloadDef for the User relationship.

View Source
var PostTagColumns = struct {
	PostID string
	TagID  string
}{
	PostID: "post_id",
	TagID:  "tag_id",
}

PostTagColumns contains all column names for the post_tags table.

View Source
var PostTagWhere = struct {
	PostID PostTagPostIDFilter
	TagID  PostTagTagIDFilter
}{
	PostID: PostTagPostIDFilter{/* contains filtered or unexported fields */},
	TagID:  PostTagTagIDFilter{/* contains filtered or unexported fields */},
}

PostTagWhere provides type-safe where clause builders for each column.

View Source
var PostWhere = struct {
	ID          PostIDFilter
	AuthorID    PostAuthorIDFilter
	Title       PostTitleFilter
	Body        PostBodyFilter
	Status      PostStatusFilter
	CreatedAt   PostCreatedAtFilter
	PublishedAt PostPublishedAtFilter
}{
	ID:          PostIDFilter{/* contains filtered or unexported fields */},
	AuthorID:    PostAuthorIDFilter{/* contains filtered or unexported fields */},
	Title:       PostTitleFilter{/* contains filtered or unexported fields */},
	Body:        PostBodyFilter{/* contains filtered or unexported fields */},
	Status:      PostStatusFilter{/* contains filtered or unexported fields */},
	CreatedAt:   PostCreatedAtFilter{/* contains filtered or unexported fields */},
	PublishedAt: PostPublishedAtFilter{/* contains filtered or unexported fields */},
}

PostWhere provides type-safe where clause builders for each column.

View Source
var TagColumns = struct {
	ID   string
	Name string
}{
	ID:   "id",
	Name: "name",
}

TagColumns contains all column names for the tags table.

View Source
var TagWhere = struct {
	ID   TagIDFilter
	Name TagNameFilter
}{
	ID:   TagIDFilter{/* contains filtered or unexported fields */},
	Name: TagNameFilter{/* contains filtered or unexported fields */},
}

TagWhere provides type-safe where clause builders for each column.

View Source
var UserColumns = struct {
	ID        string
	Email     string
	Name      string
	Bio       string
	CreatedAt string
}{
	ID:        "id",
	Email:     "email",
	Name:      "name",
	Bio:       "bio",
	CreatedAt: "created_at",
}

UserColumns contains all column names for the users table.

View Source
var UserWhere = struct {
	ID        UserIDFilter
	Email     UserEmailFilter
	Name      UserNameFilter
	Bio       UserBioFilter
	CreatedAt UserCreatedAtFilter
}{
	ID:        UserIDFilter{/* contains filtered or unexported fields */},
	Email:     UserEmailFilter{/* contains filtered or unexported fields */},
	Name:      UserNameFilter{/* contains filtered or unexported fields */},
	Bio:       UserBioFilter{/* contains filtered or unexported fields */},
	CreatedAt: UserCreatedAtFilter{/* contains filtered or unexported fields */},
}

UserWhere provides type-safe where clause builders for each column.

Functions

func AddPostHook

func AddPostHook(point sqlgen.HookPoint, fn PostHook)

AddPostHook registers a typed hook for the given hook point. The hook receives the model pointer and can inspect or modify it.

func AddPostTagHook

func AddPostTagHook(point sqlgen.HookPoint, fn PostTagHook)

AddPostTagHook registers a typed hook for the given hook point. The hook receives the model pointer and can inspect or modify it.

func AddTagHook

func AddTagHook(point sqlgen.HookPoint, fn TagHook)

AddTagHook registers a typed hook for the given hook point. The hook receives the model pointer and can inspect or modify it.

func AddUserHook

func AddUserHook(point sqlgen.HookPoint, fn UserHook)

AddUserHook registers a typed hook for the given hook point. The hook receives the model pointer and can inspect or modify it.

func CountPostTags

func CountPostTags(ctx context.Context, exec sqlgen.Executor, mods ...sqlgen.QueryMod) (int64, error)

CountPostTags returns the count of rows matching the query mods.

func CountPosts

func CountPosts(ctx context.Context, exec sqlgen.Executor, mods ...sqlgen.QueryMod) (int64, error)

CountPosts returns the count of rows matching the query mods.

func CountTags

func CountTags(ctx context.Context, exec sqlgen.Executor, mods ...sqlgen.QueryMod) (int64, error)

CountTags returns the count of rows matching the query mods.

func CountUsers

func CountUsers(ctx context.Context, exec sqlgen.Executor, mods ...sqlgen.QueryMod) (int64, error)

CountUsers returns the count of rows matching the query mods.

func DeleteAllPostTags

func DeleteAllPostTags(ctx context.Context, exec sqlgen.Executor, mods ...sqlgen.QueryMod) (int64, error)

DeleteAllPostTags deletes all rows matching the given mods.

func DeleteAllPosts

func DeleteAllPosts(ctx context.Context, exec sqlgen.Executor, mods ...sqlgen.QueryMod) (int64, error)

DeleteAllPosts deletes all rows matching the given mods.

func DeleteAllTags

func DeleteAllTags(ctx context.Context, exec sqlgen.Executor, mods ...sqlgen.QueryMod) (int64, error)

DeleteAllTags deletes all rows matching the given mods.

func DeleteAllUsers

func DeleteAllUsers(ctx context.Context, exec sqlgen.Executor, mods ...sqlgen.QueryMod) (int64, error)

DeleteAllUsers deletes all rows matching the given mods.

func EachPost

func EachPost(ctx context.Context, exec sqlgen.Executor, fn func(*Post) error, mods ...sqlgen.QueryMod) error

EachPost executes a query and calls fn for each row. Iteration stops early if fn returns an error. Rows are not accumulated in memory.

func EachPostTag

func EachPostTag(ctx context.Context, exec sqlgen.Executor, fn func(*PostTag) error, mods ...sqlgen.QueryMod) error

EachPostTag executes a query and calls fn for each row. Iteration stops early if fn returns an error. Rows are not accumulated in memory.

func EachTag

func EachTag(ctx context.Context, exec sqlgen.Executor, fn func(*Tag) error, mods ...sqlgen.QueryMod) error

EachTag executes a query and calls fn for each row. Iteration stops early if fn returns an error. Rows are not accumulated in memory.

func EachUser

func EachUser(ctx context.Context, exec sqlgen.Executor, fn func(*User) error, mods ...sqlgen.QueryMod) error

EachUser executes a query and calls fn for each row. Iteration stops early if fn returns an error. Rows are not accumulated in memory.

func PostCursor

func PostCursor(ctx context.Context, exec sqlgen.Executor, mods ...sqlgen.QueryMod) (*sqlgen.Cursor[*Post], error)

PostCursor returns a cursor for iterating over posts rows one at a time.

func PostExists

func PostExists(ctx context.Context, exec sqlgen.Executor, id string) (bool, error)

Exists checks if a row with the given primary key exists.

func PostTagCursor

func PostTagCursor(ctx context.Context, exec sqlgen.Executor, mods ...sqlgen.QueryMod) (*sqlgen.Cursor[*PostTag], error)

PostTagCursor returns a cursor for iterating over post_tags rows one at a time.

func PostTagExists

func PostTagExists(ctx context.Context, exec sqlgen.Executor, postID string, tagID int32) (bool, error)

Exists checks if a row with the given primary key exists.

func PostTags

func PostTags(mods ...sqlgen.QueryMod) *sqlgen.Query

PostTags returns a query builder for the post_tags table.

func Posts

func Posts(mods ...sqlgen.QueryMod) *sqlgen.Query

Posts returns a query builder for the posts table.

func TagCursor

func TagCursor(ctx context.Context, exec sqlgen.Executor, mods ...sqlgen.QueryMod) (*sqlgen.Cursor[*Tag], error)

TagCursor returns a cursor for iterating over tags rows one at a time.

func TagExists

func TagExists(ctx context.Context, exec sqlgen.Executor, id int32) (bool, error)

Exists checks if a row with the given primary key exists.

func Tags

func Tags(mods ...sqlgen.QueryMod) *sqlgen.Query

Tags returns a query builder for the tags table.

func UpdateAllPostTags

func UpdateAllPostTags(ctx context.Context, exec sqlgen.Executor, set map[string]any, mods ...sqlgen.QueryMod) (int64, error)

UpdateAllPostTags updates all rows matching the given mods. set is a map of column name -> new value.

func UpdateAllPosts

func UpdateAllPosts(ctx context.Context, exec sqlgen.Executor, set map[string]any, mods ...sqlgen.QueryMod) (int64, error)

UpdateAllPosts updates all rows matching the given mods. set is a map of column name -> new value.

func UpdateAllTags

func UpdateAllTags(ctx context.Context, exec sqlgen.Executor, set map[string]any, mods ...sqlgen.QueryMod) (int64, error)

UpdateAllTags updates all rows matching the given mods. set is a map of column name -> new value.

func UpdateAllUsers

func UpdateAllUsers(ctx context.Context, exec sqlgen.Executor, set map[string]any, mods ...sqlgen.QueryMod) (int64, error)

UpdateAllUsers updates all rows matching the given mods. set is a map of column name -> new value.

func UserCursor

func UserCursor(ctx context.Context, exec sqlgen.Executor, mods ...sqlgen.QueryMod) (*sqlgen.Cursor[*User], error)

UserCursor returns a cursor for iterating over users rows one at a time.

func UserExists

func UserExists(ctx context.Context, exec sqlgen.Executor, id string) (bool, error)

Exists checks if a row with the given primary key exists.

func Users

func Users(mods ...sqlgen.QueryMod) *sqlgen.Query

Users returns a query builder for the users table.

Types

type Post

type Post struct {
	ID          string                 `db:"id" json:"id"`
	AuthorID    string                 `db:"author_id" json:"author_id"`
	Title       string                 `db:"title" json:"title"`
	Body        string                 `db:"body" json:"body"`
	Status      PostStatus             `db:"status" json:"status"`
	CreatedAt   time.Time              `db:"created_at" json:"created_at"`
	PublishedAt sqlgen.Null[time.Time] `db:"published_at" json:"published_at"`

	R *PostRels `db:"-" json:"-"`
}

Post represents a row from the 'posts' table.

func FindPostByPK

func FindPostByPK(ctx context.Context, exec sqlgen.Executor, id string) (*Post, error)

FindPostByPK finds a Post by primary key.

func (*Post) AddTags

func (o *Post) AddTags(ctx context.Context, exec sqlgen.Executor, related ...*Tag) error

AddTags adds to the Tags relationship by inserting join table rows.

func (*Post) Delete

func (o *Post) Delete(ctx context.Context, exec sqlgen.Executor) error

Delete deletes the Post from the database.

func (*Post) Insert

func (o *Post) Insert(ctx context.Context, exec sqlgen.Executor, cols ...sqlgen.Columns) error

Insert inserts the Post into the database. Optional Columns parameter controls which columns are included (Whitelist/Blacklist).

func (*Post) Reload

func (o *Post) Reload(ctx context.Context, exec sqlgen.Executor) error

Reload refreshes the Post from the database using its primary key.

func (*Post) RemoveTags

func (o *Post) RemoveTags(ctx context.Context, exec sqlgen.Executor, related ...*Tag) error

RemoveTags removes from the Tags relationship by deleting join table rows.

func (*Post) ScanRow

func (o *Post) ScanRow(rows interface{ Scan(...any) error }) error

ScanRow scans a database row into a Post.

func (*Post) SetTags

func (o *Post) SetTags(ctx context.Context, exec sqlgen.Executor, related ...*Tag) error

SetTags replaces the Tags relationship entirely. Deletes all existing join rows, then inserts new ones.

func (*Post) SetUser

func (o *Post) SetUser(ctx context.Context, exec sqlgen.Executor, related *User) error

SetUser sets the User relationship by updating the FK column.

func (*Post) Update

func (o *Post) Update(ctx context.Context, exec sqlgen.Executor, cols ...sqlgen.Columns) error

Update updates the Post in the database. Only non-PK columns are updated. Optional Columns parameter controls which columns are included (Whitelist/Blacklist).

func (*Post) Upsert

func (o *Post) Upsert(ctx context.Context, exec sqlgen.Executor, cols ...sqlgen.Columns) error

Upsert inserts or updates the Post based on the primary key. Optional Columns parameter controls which non-PK columns are included (Whitelist/Blacklist).

type PostAuthorIDFilter

type PostAuthorIDFilter struct {
	// contains filtered or unexported fields
}

PostAuthorIDFilter provides where clauses for the author_id column.

func (PostAuthorIDFilter) EQ

func (PostAuthorIDFilter) GT

func (PostAuthorIDFilter) GTE

func (PostAuthorIDFilter) IN

func (f PostAuthorIDFilter) IN(vals ...string) sqlgen.QueryMod

func (PostAuthorIDFilter) LT

func (PostAuthorIDFilter) LTE

func (PostAuthorIDFilter) NEQ

type PostBodyFilter

type PostBodyFilter struct {
	// contains filtered or unexported fields
}

PostBodyFilter provides where clauses for the body column.

func (PostBodyFilter) EQ

func (PostBodyFilter) GT

func (PostBodyFilter) GTE

func (f PostBodyFilter) GTE(val string) sqlgen.QueryMod

func (PostBodyFilter) IN

func (f PostBodyFilter) IN(vals ...string) sqlgen.QueryMod

func (PostBodyFilter) LT

func (PostBodyFilter) LTE

func (f PostBodyFilter) LTE(val string) sqlgen.QueryMod

func (PostBodyFilter) NEQ

func (f PostBodyFilter) NEQ(val string) sqlgen.QueryMod

type PostCreatedAtFilter

type PostCreatedAtFilter struct {
	// contains filtered or unexported fields
}

PostCreatedAtFilter provides where clauses for the created_at column.

func (PostCreatedAtFilter) EQ

func (PostCreatedAtFilter) GT

func (PostCreatedAtFilter) GTE

func (PostCreatedAtFilter) IN

func (PostCreatedAtFilter) LT

func (PostCreatedAtFilter) LTE

func (PostCreatedAtFilter) NEQ

type PostHook

type PostHook func(ctx context.Context, exec sqlgen.Executor, model *Post) (context.Context, error)

PostHook is a typed hook function for Post lifecycle events.

type PostIDFilter

type PostIDFilter struct {
	// contains filtered or unexported fields
}

PostIDFilter provides where clauses for the id column.

func (PostIDFilter) EQ

func (f PostIDFilter) EQ(val string) sqlgen.QueryMod

func (PostIDFilter) GT

func (f PostIDFilter) GT(val string) sqlgen.QueryMod

func (PostIDFilter) GTE

func (f PostIDFilter) GTE(val string) sqlgen.QueryMod

func (PostIDFilter) IN

func (f PostIDFilter) IN(vals ...string) sqlgen.QueryMod

func (PostIDFilter) LT

func (f PostIDFilter) LT(val string) sqlgen.QueryMod

func (PostIDFilter) LTE

func (f PostIDFilter) LTE(val string) sqlgen.QueryMod

func (PostIDFilter) NEQ

func (f PostIDFilter) NEQ(val string) sqlgen.QueryMod

type PostPublishedAtFilter

type PostPublishedAtFilter struct {
	// contains filtered or unexported fields
}

PostPublishedAtFilter provides where clauses for the published_at column.

func (PostPublishedAtFilter) EQ

func (PostPublishedAtFilter) GT

func (PostPublishedAtFilter) GTE

func (PostPublishedAtFilter) IN

func (PostPublishedAtFilter) IsNotNull

func (f PostPublishedAtFilter) IsNotNull() sqlgen.QueryMod

func (PostPublishedAtFilter) IsNull

func (PostPublishedAtFilter) LT

func (PostPublishedAtFilter) LTE

func (PostPublishedAtFilter) NEQ

type PostRels

type PostRels struct {
	User      *User
	Tags      []*Tag
	TagsCount *int64
}

PostRels holds eagerly loaded relationships.

type PostSlice

type PostSlice []*Post

PostSlice is a slice of Post pointers.

func AllPosts

func AllPosts(ctx context.Context, exec sqlgen.Executor, mods ...sqlgen.QueryMod) (PostSlice, error)

AllPosts retrieves all rows from the posts table with the given query mods. Supports Preload() for LEFT JOIN eager loading of to-one relationships.

func (PostSlice) DeleteAll

func (s PostSlice) DeleteAll(ctx context.Context, exec sqlgen.Executor) (int64, error)

DeleteAll deletes all models in the slice.

func (PostSlice) InsertAll

func (s PostSlice) InsertAll(ctx context.Context, exec sqlgen.Executor) error

InsertAll batch-inserts all models in the slice. Each model's columns are scanned back via RETURNING, picking up defaults and generated values. Hooks are not fired (consistent with UpdateAll/DeleteAll).

func (PostSlice) LoadCountRelations

func (s PostSlice) LoadCountRelations(ctx context.Context, exec sqlgen.Executor, names ...string) error

LoadCountRelations loads counts for the specified relationships. Pass relationship names (e.g., "Posts", "Tags") to load their counts.

func (PostSlice) LoadRelations

func (s PostSlice) LoadRelations(ctx context.Context, exec sqlgen.Executor, loads ...*sqlgen.EagerLoadRequest) error

LoadRelations eagerly loads the specified relationships for a slice of Post.

func (PostSlice) UpdateAll

func (s PostSlice) UpdateAll(ctx context.Context, exec sqlgen.Executor, set map[string]any) (int64, error)

UpdateAll updates all models in the slice with the given column values.

type PostStatus

type PostStatus string

PostStatus is the 'post_status' enum type.

const (
	PostStatusDraft     PostStatus = "draft"
	PostStatusPublished PostStatus = "published"
	PostStatusArchived  PostStatus = "archived"
)

func AllPostStatusValues

func AllPostStatusValues() []PostStatus

AllPostStatusValues returns all valid values for this enum.

func (PostStatus) IsValid

func (e PostStatus) IsValid() bool

IsValid checks if the value is a valid enum value.

func (*PostStatus) Scan

func (e *PostStatus) Scan(src any) error

Scan implements sql.Scanner.

func (PostStatus) String

func (e PostStatus) String() string

String returns the string representation.

func (PostStatus) Value

func (e PostStatus) Value() (driver.Value, error)

Value implements driver.Valuer.

type PostStatusFilter

type PostStatusFilter struct {
	// contains filtered or unexported fields
}

PostStatusFilter provides where clauses for the status column.

func (PostStatusFilter) EQ

func (PostStatusFilter) GT

func (PostStatusFilter) GTE

func (PostStatusFilter) IN

func (PostStatusFilter) LT

func (PostStatusFilter) LTE

func (PostStatusFilter) NEQ

type PostTag

type PostTag struct {
	PostID string `db:"post_id" json:"post_id"`
	TagID  int32  `db:"tag_id" json:"tag_id"`

	R *PostTagRels `db:"-" json:"-"`
}

PostTag represents a row from the 'post_tags' table.

func FindPostTagByPK

func FindPostTagByPK(ctx context.Context, exec sqlgen.Executor, postID string, tagID int32) (*PostTag, error)

FindPostTagByPK finds a PostTag by primary key.

func (*PostTag) Delete

func (o *PostTag) Delete(ctx context.Context, exec sqlgen.Executor) error

Delete deletes the PostTag from the database.

func (*PostTag) Insert

func (o *PostTag) Insert(ctx context.Context, exec sqlgen.Executor, cols ...sqlgen.Columns) error

Insert inserts the PostTag into the database. Optional Columns parameter controls which columns are included (Whitelist/Blacklist).

func (*PostTag) Reload

func (o *PostTag) Reload(ctx context.Context, exec sqlgen.Executor) error

Reload refreshes the PostTag from the database using its primary key.

func (*PostTag) ScanRow

func (o *PostTag) ScanRow(rows interface{ Scan(...any) error }) error

ScanRow scans a database row into a PostTag.

func (*PostTag) Update

func (o *PostTag) Update(ctx context.Context, exec sqlgen.Executor, cols ...sqlgen.Columns) error

Update updates the PostTag in the database. Only non-PK columns are updated. Optional Columns parameter controls which columns are included (Whitelist/Blacklist).

func (*PostTag) Upsert

func (o *PostTag) Upsert(ctx context.Context, exec sqlgen.Executor, cols ...sqlgen.Columns) error

Upsert inserts or updates the PostTag based on the primary key. Optional Columns parameter controls which non-PK columns are included (Whitelist/Blacklist).

type PostTagHook

type PostTagHook func(ctx context.Context, exec sqlgen.Executor, model *PostTag) (context.Context, error)

PostTagHook is a typed hook function for PostTag lifecycle events.

type PostTagPostIDFilter

type PostTagPostIDFilter struct {
	// contains filtered or unexported fields
}

PostTagPostIDFilter provides where clauses for the post_id column.

func (PostTagPostIDFilter) EQ

func (PostTagPostIDFilter) GT

func (PostTagPostIDFilter) GTE

func (PostTagPostIDFilter) IN

func (f PostTagPostIDFilter) IN(vals ...string) sqlgen.QueryMod

func (PostTagPostIDFilter) LT

func (PostTagPostIDFilter) LTE

func (PostTagPostIDFilter) NEQ

type PostTagRels

type PostTagRels struct {
}

PostTagRels holds eagerly loaded relationships.

type PostTagSlice

type PostTagSlice []*PostTag

PostTagSlice is a slice of PostTag pointers.

func AllPostTags

func AllPostTags(ctx context.Context, exec sqlgen.Executor, mods ...sqlgen.QueryMod) (PostTagSlice, error)

AllPostTags retrieves all rows from the post_tags table with the given query mods. Supports Preload() for LEFT JOIN eager loading of to-one relationships.

type PostTagTagIDFilter

type PostTagTagIDFilter struct {
	// contains filtered or unexported fields
}

PostTagTagIDFilter provides where clauses for the tag_id column.

func (PostTagTagIDFilter) EQ

func (PostTagTagIDFilter) GT

func (PostTagTagIDFilter) GTE

func (PostTagTagIDFilter) IN

func (f PostTagTagIDFilter) IN(vals ...int32) sqlgen.QueryMod

func (PostTagTagIDFilter) LT

func (PostTagTagIDFilter) LTE

func (PostTagTagIDFilter) NEQ

type PostTitleFilter

type PostTitleFilter struct {
	// contains filtered or unexported fields
}

PostTitleFilter provides where clauses for the title column.

func (PostTitleFilter) EQ

func (PostTitleFilter) GT

func (PostTitleFilter) GTE

func (PostTitleFilter) IN

func (f PostTitleFilter) IN(vals ...string) sqlgen.QueryMod

func (PostTitleFilter) LT

func (PostTitleFilter) LTE

func (PostTitleFilter) NEQ

type Tag

type Tag struct {
	ID   int32  `db:"id" json:"id"`
	Name string `db:"name" json:"name"`

	R *TagRels `db:"-" json:"-"`
}

Tag represents a row from the 'tags' table.

func FindTagByPK

func FindTagByPK(ctx context.Context, exec sqlgen.Executor, id int32) (*Tag, error)

FindTagByPK finds a Tag by primary key.

func (*Tag) AddPosts

func (o *Tag) AddPosts(ctx context.Context, exec sqlgen.Executor, related ...*Post) error

AddPosts adds to the Posts relationship by inserting join table rows.

func (*Tag) Delete

func (o *Tag) Delete(ctx context.Context, exec sqlgen.Executor) error

Delete deletes the Tag from the database.

func (*Tag) Insert

func (o *Tag) Insert(ctx context.Context, exec sqlgen.Executor, cols ...sqlgen.Columns) error

Insert inserts the Tag into the database. Optional Columns parameter controls which columns are included (Whitelist/Blacklist).

func (*Tag) Reload

func (o *Tag) Reload(ctx context.Context, exec sqlgen.Executor) error

Reload refreshes the Tag from the database using its primary key.

func (*Tag) RemovePosts

func (o *Tag) RemovePosts(ctx context.Context, exec sqlgen.Executor, related ...*Post) error

RemovePosts removes from the Posts relationship by deleting join table rows.

func (*Tag) ScanRow

func (o *Tag) ScanRow(rows interface{ Scan(...any) error }) error

ScanRow scans a database row into a Tag.

func (*Tag) SetPosts

func (o *Tag) SetPosts(ctx context.Context, exec sqlgen.Executor, related ...*Post) error

SetPosts replaces the Posts relationship entirely. Deletes all existing join rows, then inserts new ones.

func (*Tag) Update

func (o *Tag) Update(ctx context.Context, exec sqlgen.Executor, cols ...sqlgen.Columns) error

Update updates the Tag in the database. Only non-PK columns are updated. Optional Columns parameter controls which columns are included (Whitelist/Blacklist).

func (*Tag) Upsert

func (o *Tag) Upsert(ctx context.Context, exec sqlgen.Executor, cols ...sqlgen.Columns) error

Upsert inserts or updates the Tag based on the primary key. Optional Columns parameter controls which non-PK columns are included (Whitelist/Blacklist).

type TagHook

type TagHook func(ctx context.Context, exec sqlgen.Executor, model *Tag) (context.Context, error)

TagHook is a typed hook function for Tag lifecycle events.

type TagIDFilter

type TagIDFilter struct {
	// contains filtered or unexported fields
}

TagIDFilter provides where clauses for the id column.

func (TagIDFilter) EQ

func (f TagIDFilter) EQ(val int32) sqlgen.QueryMod

func (TagIDFilter) GT

func (f TagIDFilter) GT(val int32) sqlgen.QueryMod

func (TagIDFilter) GTE

func (f TagIDFilter) GTE(val int32) sqlgen.QueryMod

func (TagIDFilter) IN

func (f TagIDFilter) IN(vals ...int32) sqlgen.QueryMod

func (TagIDFilter) LT

func (f TagIDFilter) LT(val int32) sqlgen.QueryMod

func (TagIDFilter) LTE

func (f TagIDFilter) LTE(val int32) sqlgen.QueryMod

func (TagIDFilter) NEQ

func (f TagIDFilter) NEQ(val int32) sqlgen.QueryMod

type TagNameFilter

type TagNameFilter struct {
	// contains filtered or unexported fields
}

TagNameFilter provides where clauses for the name column.

func (TagNameFilter) EQ

func (f TagNameFilter) EQ(val string) sqlgen.QueryMod

func (TagNameFilter) GT

func (f TagNameFilter) GT(val string) sqlgen.QueryMod

func (TagNameFilter) GTE

func (f TagNameFilter) GTE(val string) sqlgen.QueryMod

func (TagNameFilter) IN

func (f TagNameFilter) IN(vals ...string) sqlgen.QueryMod

func (TagNameFilter) LT

func (f TagNameFilter) LT(val string) sqlgen.QueryMod

func (TagNameFilter) LTE

func (f TagNameFilter) LTE(val string) sqlgen.QueryMod

func (TagNameFilter) NEQ

func (f TagNameFilter) NEQ(val string) sqlgen.QueryMod

type TagRels

type TagRels struct {
	Posts      []*Post
	PostsCount *int64
}

TagRels holds eagerly loaded relationships.

type TagSlice

type TagSlice []*Tag

TagSlice is a slice of Tag pointers.

func AllTags

func AllTags(ctx context.Context, exec sqlgen.Executor, mods ...sqlgen.QueryMod) (TagSlice, error)

AllTags retrieves all rows from the tags table with the given query mods. Supports Preload() for LEFT JOIN eager loading of to-one relationships.

func (TagSlice) DeleteAll

func (s TagSlice) DeleteAll(ctx context.Context, exec sqlgen.Executor) (int64, error)

DeleteAll deletes all models in the slice.

func (TagSlice) InsertAll

func (s TagSlice) InsertAll(ctx context.Context, exec sqlgen.Executor) error

InsertAll batch-inserts all models in the slice. Each model's columns are scanned back via RETURNING, picking up defaults and generated values. Hooks are not fired (consistent with UpdateAll/DeleteAll).

func (TagSlice) LoadCountRelations

func (s TagSlice) LoadCountRelations(ctx context.Context, exec sqlgen.Executor, names ...string) error

LoadCountRelations loads counts for the specified relationships. Pass relationship names (e.g., "Posts", "Tags") to load their counts.

func (TagSlice) LoadRelations

func (s TagSlice) LoadRelations(ctx context.Context, exec sqlgen.Executor, loads ...*sqlgen.EagerLoadRequest) error

LoadRelations eagerly loads the specified relationships for a slice of Tag.

func (TagSlice) UpdateAll

func (s TagSlice) UpdateAll(ctx context.Context, exec sqlgen.Executor, set map[string]any) (int64, error)

UpdateAll updates all models in the slice with the given column values.

type User

type User struct {
	ID        string              `db:"id" json:"id"`
	Email     string              `db:"email" json:"email"`
	Name      string              `db:"name" json:"name"`
	Bio       sqlgen.Null[string] `db:"bio" json:"bio"`
	CreatedAt time.Time           `db:"created_at" json:"created_at"`

	R *UserRels `db:"-" json:"-"`
}

User represents a row from the 'users' table.

func FindUserByPK

func FindUserByPK(ctx context.Context, exec sqlgen.Executor, id string) (*User, error)

FindUserByPK finds a User by primary key.

func (*User) AddPosts

func (o *User) AddPosts(ctx context.Context, exec sqlgen.Executor, related ...*Post) error

AddPosts adds models to the Posts relationship by setting their FK.

func (*User) Delete

func (o *User) Delete(ctx context.Context, exec sqlgen.Executor) error

Delete deletes the User from the database.

func (*User) Insert

func (o *User) Insert(ctx context.Context, exec sqlgen.Executor, cols ...sqlgen.Columns) error

Insert inserts the User into the database. Optional Columns parameter controls which columns are included (Whitelist/Blacklist).

func (*User) Reload

func (o *User) Reload(ctx context.Context, exec sqlgen.Executor) error

Reload refreshes the User from the database using its primary key.

func (*User) ScanRow

func (o *User) ScanRow(rows interface{ Scan(...any) error }) error

ScanRow scans a database row into a User.

func (*User) Update

func (o *User) Update(ctx context.Context, exec sqlgen.Executor, cols ...sqlgen.Columns) error

Update updates the User in the database. Only non-PK columns are updated. Optional Columns parameter controls which columns are included (Whitelist/Blacklist).

func (*User) Upsert

func (o *User) Upsert(ctx context.Context, exec sqlgen.Executor, cols ...sqlgen.Columns) error

Upsert inserts or updates the User based on the primary key. Optional Columns parameter controls which non-PK columns are included (Whitelist/Blacklist).

type UserBioFilter

type UserBioFilter struct {
	// contains filtered or unexported fields
}

UserBioFilter provides where clauses for the bio column.

func (UserBioFilter) EQ

func (UserBioFilter) GT

func (UserBioFilter) GTE

func (UserBioFilter) IN

func (f UserBioFilter) IN(vals ...sqlgen.Null[string]) sqlgen.QueryMod

func (UserBioFilter) IsNotNull

func (f UserBioFilter) IsNotNull() sqlgen.QueryMod

func (UserBioFilter) IsNull

func (f UserBioFilter) IsNull() sqlgen.QueryMod

func (UserBioFilter) LT

func (UserBioFilter) LTE

func (UserBioFilter) NEQ

type UserCreatedAtFilter

type UserCreatedAtFilter struct {
	// contains filtered or unexported fields
}

UserCreatedAtFilter provides where clauses for the created_at column.

func (UserCreatedAtFilter) EQ

func (UserCreatedAtFilter) GT

func (UserCreatedAtFilter) GTE

func (UserCreatedAtFilter) IN

func (UserCreatedAtFilter) LT

func (UserCreatedAtFilter) LTE

func (UserCreatedAtFilter) NEQ

type UserEmailFilter

type UserEmailFilter struct {
	// contains filtered or unexported fields
}

UserEmailFilter provides where clauses for the email column.

func (UserEmailFilter) EQ

func (UserEmailFilter) GT

func (UserEmailFilter) GTE

func (UserEmailFilter) IN

func (f UserEmailFilter) IN(vals ...string) sqlgen.QueryMod

func (UserEmailFilter) LT

func (UserEmailFilter) LTE

func (UserEmailFilter) NEQ

type UserHook

type UserHook func(ctx context.Context, exec sqlgen.Executor, model *User) (context.Context, error)

UserHook is a typed hook function for User lifecycle events.

type UserIDFilter

type UserIDFilter struct {
	// contains filtered or unexported fields
}

UserIDFilter provides where clauses for the id column.

func (UserIDFilter) EQ

func (f UserIDFilter) EQ(val string) sqlgen.QueryMod

func (UserIDFilter) GT

func (f UserIDFilter) GT(val string) sqlgen.QueryMod

func (UserIDFilter) GTE

func (f UserIDFilter) GTE(val string) sqlgen.QueryMod

func (UserIDFilter) IN

func (f UserIDFilter) IN(vals ...string) sqlgen.QueryMod

func (UserIDFilter) LT

func (f UserIDFilter) LT(val string) sqlgen.QueryMod

func (UserIDFilter) LTE

func (f UserIDFilter) LTE(val string) sqlgen.QueryMod

func (UserIDFilter) NEQ

func (f UserIDFilter) NEQ(val string) sqlgen.QueryMod

type UserNameFilter

type UserNameFilter struct {
	// contains filtered or unexported fields
}

UserNameFilter provides where clauses for the name column.

func (UserNameFilter) EQ

func (UserNameFilter) GT

func (UserNameFilter) GTE

func (f UserNameFilter) GTE(val string) sqlgen.QueryMod

func (UserNameFilter) IN

func (f UserNameFilter) IN(vals ...string) sqlgen.QueryMod

func (UserNameFilter) LT

func (UserNameFilter) LTE

func (f UserNameFilter) LTE(val string) sqlgen.QueryMod

func (UserNameFilter) NEQ

func (f UserNameFilter) NEQ(val string) sqlgen.QueryMod

type UserRels

type UserRels struct {
	Posts      []*Post
	PostsCount *int64
}

UserRels holds eagerly loaded relationships.

type UserSlice

type UserSlice []*User

UserSlice is a slice of User pointers.

func AllUsers

func AllUsers(ctx context.Context, exec sqlgen.Executor, mods ...sqlgen.QueryMod) (UserSlice, error)

AllUsers retrieves all rows from the users table with the given query mods. Supports Preload() for LEFT JOIN eager loading of to-one relationships.

func (UserSlice) DeleteAll

func (s UserSlice) DeleteAll(ctx context.Context, exec sqlgen.Executor) (int64, error)

DeleteAll deletes all models in the slice.

func (UserSlice) InsertAll

func (s UserSlice) InsertAll(ctx context.Context, exec sqlgen.Executor) error

InsertAll batch-inserts all models in the slice. Each model's columns are scanned back via RETURNING, picking up defaults and generated values. Hooks are not fired (consistent with UpdateAll/DeleteAll).

func (UserSlice) LoadCountRelations

func (s UserSlice) LoadCountRelations(ctx context.Context, exec sqlgen.Executor, names ...string) error

LoadCountRelations loads counts for the specified relationships. Pass relationship names (e.g., "Posts", "Tags") to load their counts.

func (UserSlice) LoadRelations

func (s UserSlice) LoadRelations(ctx context.Context, exec sqlgen.Executor, loads ...*sqlgen.EagerLoadRequest) error

LoadRelations eagerly loads the specified relationships for a slice of User.

func (UserSlice) UpdateAll

func (s UserSlice) UpdateAll(ctx context.Context, exec sqlgen.Executor, set map[string]any) (int64, error)

UpdateAll updates all models in the slice with the given column values.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL