Documentation
¶
Index ¶
- type Config
- type DB
- func (db *DB) Assign(attrs ...interface{}) db.IDB
- func (db *DB) Attrs(attrs ...interface{}) db.IDB
- func (db *DB) Distinct(args ...interface{}) db.IDB
- func (db *DB) Group(name string) db.IDB
- func (db *DB) Having(query interface{}, args ...interface{}) db.IDB
- func (db *DB) Joins(query string, args ...interface{}) db.IDB
- func (db *DB) Limit(limit int) db.IDB
- func (db *DB) Model(value interface{}) db.IDB
- func (db *DB) Not(query interface{}, args ...interface{}) db.IDB
- func (db *DB) Offset(offset int) db.IDB
- func (db *DB) Omit(columns ...string) db.IDB
- func (db *DB) Or(query interface{}, args ...interface{}) db.IDB
- func (db *DB) Order(value interface{}) db.IDB
- func (db *DB) Preload(query string, args ...interface{}) db.IDB
- func (db *DB) Raw(sql string, values ...interface{}) db.IDB
- func (db *DB) Select(query interface{}, args ...interface{}) db.IDB
- func (db *DB) Table(name string, args ...interface{}) db.IDB
- func (db *DB) Unscoped() db.IDB
- func (db *DB) Where(query interface{}, args ...interface{}) db.IDB
- type LogSql
- func (l *LogSql) Error(ctx context.Context, msg string, data ...interface{})
- func (l *LogSql) Info(ctx context.Context, msg string, data ...interface{})
- func (l *LogSql) LogMode(level logger.LogLevel) logger.Interface
- func (l *LogSql) Trace(ctx context.Context, begin time.Time, ...)
- func (l *LogSql) Warn(ctx context.Context, msg string, data ...interface{})
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶ added in v0.2.7
type DB ¶ added in v0.2.1
func (*DB) Joins ¶ added in v0.2.1
Joins specify Joins conditions
db.Joins("Account").Find(&user) db.Joins("JOIN emails ON emails.user_id = users.id AND emails.email = ?", "jinzhu@example.org").Find(&user) db.Joins("Account", DB.Select("id").Where("user_id = users.id AND name = ?", "someName").Model(&Account{}))
func (*DB) Model ¶ added in v0.2.1
Model specify the model you would like to run db operations
// update all users is name to `hello` db.Model(&User{}).Update("name", "hello") // if user's primary key is non-blank, will use it as condition, then will only update the user's name to `hello` db.Model(&user).Update("name", "hello")
func (*DB) Offset ¶ added in v0.2.1
Offset specify the number of records to skip before starting to return the records
func (*DB) Omit ¶ added in v0.2.1
Omit specify fields that you want to ignore when creating, updating and querying
func (*DB) Order ¶ added in v0.2.1
Order specify order when retrieve records from database
db.Order("name DESC") db.Order(clause.OrderByColumn{Column: clause.Column{Name: "name"}, Desc: true})
func (*DB) Preload ¶ added in v0.2.1
Preload associations with given conditions
db.Preload("Orders", "state NOT IN (?)", "cancelled").Find(&users)
func (*DB) Select ¶ added in v0.2.1
Select specify fields that you want when querying, creating, updating
Click to show internal directories.
Click to hide internal directories.