models

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2019 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrSyncFail = errors.New("models: failed to synchronize data after insert")

ErrSyncFail occurs during insert when the record could not be retrieved in order to populate default value information. This usually happens when LastInsertId fails or there was a primary key configuration that was not resolvable.

View Source
var PostColumns = struct {
	ID      string
	Title   string
	Content string
	Date    string
	UserID  string
}{
	ID:      "id",
	Title:   "title",
	Content: "content",
	Date:    "date",
	UserID:  "user_id",
}
View Source
var PostRels = struct {
	User string
}{
	User: "User",
}

PostRels is where relationship names are stored.

View Source
var PostWhere = struct {
	ID      whereHelperint
	Title   whereHelperstring
	Content whereHelperstring
	Date    whereHelpertime_Time
	UserID  whereHelperint
}{
	ID:      whereHelperint{/* contains filtered or unexported fields */},
	Title:   whereHelperstring{/* contains filtered or unexported fields */},
	Content: whereHelperstring{/* contains filtered or unexported fields */},
	Date:    whereHelpertime_Time{/* contains filtered or unexported fields */},
	UserID:  whereHelperint{/* contains filtered or unexported fields */},
}
View Source
var TableNames = struct {
	Followers string
	Posts     string
	Users     string
}{
	Followers: "followers",
	Posts:     "posts",
	Users:     "users",
}
View Source
var UserColumns = struct {
	ID        string
	Username  string
	Password  string
	BirthDate string
	Bio       string
	Hometown  string
}{
	ID:        "id",
	Username:  "username",
	Password:  "password",
	BirthDate: "birth_date",
	Bio:       "bio",
	Hometown:  "hometown",
}
View Source
var UserRels = struct {
	TargetUsers   string
	FollowerUsers string
	Posts         string
}{
	TargetUsers:   "TargetUsers",
	FollowerUsers: "FollowerUsers",
	Posts:         "Posts",
}

UserRels is where relationship names are stored.

View Source
var UserWhere = struct {
	ID        whereHelperint
	Username  whereHelperstring
	Password  whereHelperstring
	BirthDate whereHelpernull_Time
	Bio       whereHelpernull_String
	Hometown  whereHelpernull_String
}{
	ID:        whereHelperint{/* contains filtered or unexported fields */},
	Username:  whereHelperstring{/* contains filtered or unexported fields */},
	Password:  whereHelperstring{/* contains filtered or unexported fields */},
	BirthDate: whereHelpernull_Time{/* contains filtered or unexported fields */},
	Bio:       whereHelpernull_String{/* contains filtered or unexported fields */},
	Hometown:  whereHelpernull_String{/* contains filtered or unexported fields */},
}

Functions

func AddPostHook

func AddPostHook(hookPoint boil.HookPoint, postHook PostHook)

AddPostHook registers your hook function for all future operations.

func AddUserHook

func AddUserHook(hookPoint boil.HookPoint, userHook UserHook)

AddUserHook registers your hook function for all future operations.

func NewQuery

func NewQuery(mods ...qm.QueryMod) *queries.Query

NewQuery initializes a new Query using the passed in QueryMods

func PostExists

func PostExists(ctx context.Context, exec boil.ContextExecutor, iD int) (bool, error)

PostExists checks if the Post row exists.

func Posts

func Posts(mods ...qm.QueryMod) postQuery

Posts retrieves all the records using an executor.

func UserExists

func UserExists(ctx context.Context, exec boil.ContextExecutor, iD int) (bool, error)

UserExists checks if the User row exists.

func Users

func Users(mods ...qm.QueryMod) userQuery

Users retrieves all the records using an executor.

Types

type M

type M map[string]interface{}

M type is for providing columns and column values to UpdateAll.

type Post

type Post struct {
	ID      int       `boil:"id" json:"id" toml:"id" yaml:"id"`
	Title   string    `boil:"title" json:"title" toml:"title" yaml:"title"`
	Content string    `boil:"content" json:"content" toml:"content" yaml:"content"`
	Date    time.Time `boil:"date" json:"date,omitempty" toml:"date" yaml:"date"`
	UserID  int       `boil:"user_id" json:"user_id" toml:"user_id" yaml:"user_id"`

	R *postR `boil:"-" json:"-" toml:"-" yaml:"-"`
	L postL  `boil:"-" json:"-" toml:"-" yaml:"-"`
}

Post is an object representing the database table.

func FindPost

func FindPost(ctx context.Context, exec boil.ContextExecutor, iD int, selectCols ...string) (*Post, error)

FindPost retrieves a single record by ID with an executor. If selectCols is empty Find will return all columns.

func (*Post) Delete

func (o *Post) Delete(ctx context.Context, exec boil.ContextExecutor) (int64, error)

Delete deletes a single Post record with an executor. Delete will match against the primary key column to find the record to delete.

func (*Post) Insert

func (o *Post) Insert(ctx context.Context, exec boil.ContextExecutor, columns boil.Columns) error

Insert a single record using an executor. See boil.Columns.InsertColumnSet documentation to understand column list inference for inserts.

func (*Post) Reload

func (o *Post) Reload(ctx context.Context, exec boil.ContextExecutor) error

Reload refetches the object from the database using the primary keys with an executor.

func (*Post) SetUser

func (o *Post) SetUser(ctx context.Context, exec boil.ContextExecutor, insert bool, related *User) error

SetUser of the post to the related item. Sets o.R.User to related. Adds o to related.R.Posts.

func (*Post) Update

func (o *Post) Update(ctx context.Context, exec boil.ContextExecutor, columns boil.Columns) (int64, error)

Update uses an executor to update the Post. See boil.Columns.UpdateColumnSet documentation to understand column list inference for updates. Update does not automatically update the record in case of default values. Use .Reload() to refresh the records.

func (*Post) Upsert

func (o *Post) Upsert(ctx context.Context, exec boil.ContextExecutor, updateOnConflict bool, conflictColumns []string, updateColumns, insertColumns boil.Columns) error

Upsert attempts an insert using an executor, and does an update or ignore on conflict. See boil.Columns documentation for how to properly use updateColumns and insertColumns.

func (*Post) User

func (o *Post) User(mods ...qm.QueryMod) userQuery

User pointed to by the foreign key.

type PostHook

type PostHook func(context.Context, boil.ContextExecutor, *Post) error

PostHook is the signature for custom Post hook methods

type PostSlice

type PostSlice []*Post

PostSlice is an alias for a slice of pointers to Post. This should generally be used opposed to []Post.

func (PostSlice) DeleteAll

func (o PostSlice) DeleteAll(ctx context.Context, exec boil.ContextExecutor) (int64, error)

DeleteAll deletes all rows in the slice, using an executor.

func (*PostSlice) ReloadAll

func (o *PostSlice) ReloadAll(ctx context.Context, exec boil.ContextExecutor) error

ReloadAll refetches every row with matching primary key column values and overwrites the original object slice with the newly updated slice.

func (PostSlice) UpdateAll

func (o PostSlice) UpdateAll(ctx context.Context, exec boil.ContextExecutor, cols M) (int64, error)

UpdateAll updates all rows with the specified column values, using an executor.

type User

type User struct {
	ID        int         `boil:"id" json:"id" toml:"id" yaml:"id"`
	Username  string      `boil:"username" json:"username" toml:"username" yaml:"username"`
	Password  string      `boil:"password" json:"password" toml:"password" yaml:"password"`
	BirthDate null.Time   `boil:"birth_date" json:"birth_date,omitempty" toml:"birth_date" yaml:"birth_date,omitempty"`
	Bio       null.String `boil:"bio" json:"bio,omitempty" toml:"bio" yaml:"bio,omitempty"`
	Hometown  null.String `boil:"hometown" json:"hometown,omitempty" toml:"hometown" yaml:"hometown,omitempty"`

	R *userR `boil:"-" json:"-" toml:"-" yaml:"-"`
	L userL  `boil:"-" json:"-" toml:"-" yaml:"-"`
}

User is an object representing the database table.

func FindUser

func FindUser(ctx context.Context, exec boil.ContextExecutor, iD int, selectCols ...string) (*User, error)

FindUser retrieves a single record by ID with an executor. If selectCols is empty Find will return all columns.

func (*User) AddFollowerUsers

func (o *User) AddFollowerUsers(ctx context.Context, exec boil.ContextExecutor, insert bool, related ...*User) error

AddFollowerUsers adds the given related objects to the existing relationships of the user, optionally inserting them as new records. Appends related to o.R.FollowerUsers. Sets related.R.TargetUsers appropriately.

func (*User) AddPosts

func (o *User) AddPosts(ctx context.Context, exec boil.ContextExecutor, insert bool, related ...*Post) error

AddPosts adds the given related objects to the existing relationships of the user, optionally inserting them as new records. Appends related to o.R.Posts. Sets related.R.User appropriately.

func (*User) AddTargetUsers

func (o *User) AddTargetUsers(ctx context.Context, exec boil.ContextExecutor, insert bool, related ...*User) error

AddTargetUsers adds the given related objects to the existing relationships of the user, optionally inserting them as new records. Appends related to o.R.TargetUsers. Sets related.R.FollowerUsers appropriately.

func (*User) Delete

func (o *User) Delete(ctx context.Context, exec boil.ContextExecutor) (int64, error)

Delete deletes a single User record with an executor. Delete will match against the primary key column to find the record to delete.

func (*User) FollowerUsers

func (o *User) FollowerUsers(mods ...qm.QueryMod) userQuery

FollowerUsers retrieves all the user's Users with an executor via id column.

func (*User) Insert

func (o *User) Insert(ctx context.Context, exec boil.ContextExecutor, columns boil.Columns) error

Insert a single record using an executor. See boil.Columns.InsertColumnSet documentation to understand column list inference for inserts.

func (*User) Posts

func (o *User) Posts(mods ...qm.QueryMod) postQuery

Posts retrieves all the post's Posts with an executor.

func (*User) Reload

func (o *User) Reload(ctx context.Context, exec boil.ContextExecutor) error

Reload refetches the object from the database using the primary keys with an executor.

func (*User) RemoveFollowerUsers

func (o *User) RemoveFollowerUsers(ctx context.Context, exec boil.ContextExecutor, related ...*User) error

RemoveFollowerUsers relationships from objects passed in. Removes related items from R.FollowerUsers (uses pointer comparison, removal does not keep order) Sets related.R.TargetUsers.

func (*User) RemoveTargetUsers

func (o *User) RemoveTargetUsers(ctx context.Context, exec boil.ContextExecutor, related ...*User) error

RemoveTargetUsers relationships from objects passed in. Removes related items from R.TargetUsers (uses pointer comparison, removal does not keep order) Sets related.R.FollowerUsers.

func (*User) SetFollowerUsers

func (o *User) SetFollowerUsers(ctx context.Context, exec boil.ContextExecutor, insert bool, related ...*User) error

SetFollowerUsers removes all previously related items of the user replacing them completely with the passed in related items, optionally inserting them as new records. Sets o.R.TargetUsers's FollowerUsers accordingly. Replaces o.R.FollowerUsers with related. Sets related.R.TargetUsers's FollowerUsers accordingly.

func (*User) SetTargetUsers

func (o *User) SetTargetUsers(ctx context.Context, exec boil.ContextExecutor, insert bool, related ...*User) error

SetTargetUsers removes all previously related items of the user replacing them completely with the passed in related items, optionally inserting them as new records. Sets o.R.FollowerUsers's TargetUsers accordingly. Replaces o.R.TargetUsers with related. Sets related.R.FollowerUsers's TargetUsers accordingly.

func (*User) TargetUsers

func (o *User) TargetUsers(mods ...qm.QueryMod) userQuery

TargetUsers retrieves all the user's Users with an executor via id column.

func (*User) Update

func (o *User) Update(ctx context.Context, exec boil.ContextExecutor, columns boil.Columns) (int64, error)

Update uses an executor to update the User. See boil.Columns.UpdateColumnSet documentation to understand column list inference for updates. Update does not automatically update the record in case of default values. Use .Reload() to refresh the records.

func (*User) Upsert

func (o *User) Upsert(ctx context.Context, exec boil.ContextExecutor, updateOnConflict bool, conflictColumns []string, updateColumns, insertColumns boil.Columns) error

Upsert attempts an insert using an executor, and does an update or ignore on conflict. See boil.Columns documentation for how to properly use updateColumns and insertColumns.

type UserHook

type UserHook func(context.Context, boil.ContextExecutor, *User) error

UserHook is the signature for custom User hook methods

type UserSlice

type UserSlice []*User

UserSlice is an alias for a slice of pointers to User. This should generally be used opposed to []User.

func (UserSlice) DeleteAll

func (o UserSlice) DeleteAll(ctx context.Context, exec boil.ContextExecutor) (int64, error)

DeleteAll deletes all rows in the slice, using an executor.

func (*UserSlice) ReloadAll

func (o *UserSlice) ReloadAll(ctx context.Context, exec boil.ContextExecutor) error

ReloadAll refetches every row with matching primary key column values and overwrites the original object slice with the newly updated slice.

func (UserSlice) UpdateAll

func (o UserSlice) UpdateAll(ctx context.Context, exec boil.ContextExecutor, cols M) (int64, error)

UpdateAll updates all rows with the specified column values, using an executor.

Jump to

Keyboard shortcuts

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