Documentation
¶
Index ¶
- type Q
- func (q Q[t]) Count(db *gorm.DB) (uint64, error)
- func (q Q[t]) CountSql(db *gorm.DB, sql string, sqlArgs ...interface{}) (uint64, error)
- func (q Q[t]) Delete(db *gorm.DB) error
- func (q Q[t]) Find(db *gorm.DB) ([]t, error)
- func (q Q[t]) FindOne(db *gorm.DB) (*t, error)
- func (q Q[t]) FindOneSql(db *gorm.DB, sql string, sqlArgs ...interface{}) (*t, error)
- func (q Q[t]) FindPaginated(db *gorm.DB, offset *uint64, limit *uint64, reverseOrder bool) ([]t, error)
- func (q Q[t]) FindPaginatedSql(db *gorm.DB, offset *uint64, limit *uint64, reverseOrder bool, sql string, ...) ([]t, error)
- func (q Q[t]) FindSql(db *gorm.DB, sql string, sqlArgs ...interface{}) ([]t, error)
- func (q Q[t]) Insert(db *gorm.DB) error
- func (q Q[t]) Join(db *gorm.DB, table, condition string) (*t, error)
- func (q Q[t]) M() *t
- func (q Q[t]) ShallowFind(db *gorm.DB) ([]t, error)
- func (q Q[t]) ShallowFindOne(db *gorm.DB) (*t, error)
- func (q Q[t]) ShallowFindOneSql(db *gorm.DB, sql string, sqlArgs ...interface{}) (*t, error)
- func (q Q[t]) ShallowFindPaginated(db *gorm.DB, offset *uint64, limit *uint64, reverseOrder bool) ([]t, error)
- func (q Q[t]) ShallowFindPaginatedSql(db *gorm.DB, offset *uint64, limit *uint64, reverseOrder bool, sql string, ...) ([]t, error)
- func (q Q[t]) ShallowFindSql(db *gorm.DB, sql string, sqlArgs ...interface{}) ([]t, error)
- func (q Q[t]) Update(db *gorm.DB) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Q ¶
type Q[t any] struct { // contains filtered or unexported fields }
Q represents a generalized struct wrapper that is used for CRUD operations on any gorm.Model.
func (Q[t]) Count ¶
Count counts the number of rows in the database that match the model. If the model implements a custom Count method, it will be used instead.
func (Q[t]) CountSql ¶
CountSql counts the number of rows in the database that match the custom SQL query and arguments. If the model implements a custom CountSql method, it will be used instead.
func (Q[t]) Delete ¶
Delete deletes the underlying model object from the database using GORM. If the model implements a custom Delete method, it will be used instead. If the model does not use gorm.Model while not implementing custom model method, it will return an error.
func (Q[t]) Find ¶
Find retrieves all instances of the underlying model from the database using GORM. If the model implements a custom Find method, it will be used instead. Instead of using gorm.ErrRecordNotFound it will return empty slice and nil error.
func (Q[t]) FindOne ¶
FindOne retrieves a single instance of the underlying model from the database using GORM. If the model implements a custom FindOne method, it will be used instead. Instead of using gorm.ErrRecordNotFound it will return nil model and nil error.
func (Q[t]) FindOneSql ¶
FindOneSql retrieves a single instance of the underlying model from the database using GORM, using a custom SQL query. If the model implements a custom FindOneSql method, it will be used instead. Instead of using gorm.ErrRecordNotFound it will return nil model and nil error.
func (Q[t]) FindPaginated ¶
func (q Q[t]) FindPaginated(db *gorm.DB, offset *uint64, limit *uint64, reverseOrder bool) ([]t, error)
FindPaginated retrieves a slice of models from the database with pagination parameters (limit and offset). If the model implements a custom FindPaginated method, it will be used instead. Instead of using gorm.ErrRecordNotFound it will return empty slice and nil error.
func (Q[t]) FindPaginatedSql ¶
func (q Q[t]) FindPaginatedSql(db *gorm.DB, offset *uint64, limit *uint64, reverseOrder bool, sql string, sqlArgs ...interface{}) ([]t, error)
FindPaginatedSql retrieves a slice of models from the database with pagination, optional reverse ordering, and with custom WHERE SQL. If the model implements a custom FindPaginatedSql method, it will be used instead. Instead of using gorm.ErrRecordNotFound it will return empty slice and nil error.
func (Q[t]) FindSql ¶
FindSql retrieves all instances of the underlying model from the database using GORM, using a custom SQL query. If the model implements a custom FindSql method, it will be used instead. Instead of using gorm.ErrRecordNotFound it will return empty slice and nil error.
func (Q[t]) Insert ¶
Insert inserts the underlying model object into the database using GORM. If the model implements a custom Insert method, it will be used instead.
func (Q[t]) Join ¶
Join retrieves a single instance of the underlying model from the database using GORM, with a join on another table using a custom condition. Instead of using gorm.ErrRecordNotFound it will return nil model and nil error.
func (Q[t]) ShallowFind ¶
ShallowFind retrieves all instances of the underlying model from the database using GORM, without preloading any associations. If the model implements a custom Find method, it will be used instead. Instead of using gorm.ErrRecordNotFound it will return empty slice and nil error.
func (Q[t]) ShallowFindOne ¶
ShallowFindOne retrieves a single instance of the underlying model from the database using GORM, without preloading any associations. If the model implements a custom FindOne method, it will be used instead. Instead of using gorm.ErrRecordNotFound it will return nil model and nil error.
func (Q[t]) ShallowFindOneSql ¶
ShallowFindOneSql retrieves a single instance of the underlying model from the database using GORM, using a custom SQL query and without preloading any associations. If the model implements a custom FindOneSql method, it will be used instead. Instead of using gorm.ErrRecordNotFound it will return nil model and nil error.
func (Q[t]) ShallowFindPaginated ¶
func (q Q[t]) ShallowFindPaginated(db *gorm.DB, offset *uint64, limit *uint64, reverseOrder bool) ([]t, error)
ShallowFindPaginated retrieves a slice of models from the database with pagination parameters (limit and offset), without preloading. If the model implements a custom FindPaginated method, it will be used instead. Instead of using gorm.ErrRecordNotFound it will return empty slice and nil error.
func (Q[t]) ShallowFindPaginatedSql ¶
func (q Q[t]) ShallowFindPaginatedSql(db *gorm.DB, offset *uint64, limit *uint64, reverseOrder bool, sql string, sqlArgs ...interface{}) ([]t, error)
ShallowFindPaginatedSql retrieves a slice of models from the database with pagination, optional reverse ordering, without preloading and with custom WHERE SQL. If the model implements a custom FindPaginatedSql method, it will be used instead. Instead of using gorm.ErrRecordNotFound it will return empty slice and nil error.
func (Q[t]) ShallowFindSql ¶
ShallowFindSql retrieves all instances of the underlying model from the database using GORM, using a custom SQL query and without preloading any associations. If the model implements a custom FindSql method, it will be used instead. Instead of using gorm.ErrRecordNotFound it will return empty slice and nil error.