Skip to content

Commit

Permalink
fix where
Browse files Browse the repository at this point in the history
  • Loading branch information
weihaoyu committed Aug 21, 2021
1 parent e1ef5da commit 7471fd7
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions orm/orm.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func Count(ctx context.Context, db *gorm.DB, model interface{}, where map[string
db = db.WithContext(ctx).Model(model)

for k, v := range where {
db.Where(k, v)
db = db.Where(k, v)
}

err = db.Count(&count).Error
Expand All @@ -41,19 +41,19 @@ func Select(ctx context.Context, db *gorm.DB, model interface{}, fields string,
db = db.WithContext(ctx).Model(model).Select(fields)

for k, v := range where {
db.Where(k, v)
db = db.Where(k, v)
}

for _, v := range group {
db.Group(v)
db = db.Group(v)
}

for k, v := range having {
db.Having(k, v)
db = db.Having(k, v)
}

for _, v := range order {
db.Order(v)
db = db.Order(v)
}

db = db.Offset(start).Limit(limit)
Expand All @@ -76,7 +76,7 @@ func Update(ctx context.Context, db *gorm.DB, model interface{}, where map[strin
db = db.WithContext(ctx).Model(model)

for k, v := range where {
db.Where(k, v)
db = db.Where(k, v)
}

res := db.Updates(updates)
Expand Down Expand Up @@ -104,7 +104,7 @@ func Delete(ctx context.Context, db *gorm.DB, model interface{}, where map[strin
db = db.WithContext(ctx)

for k, v := range where {
db.Where(k, v)
db = db.Where(k, v)
}

res := db.Delete(model)
Expand All @@ -120,7 +120,7 @@ func WithWhere(ctx context.Context, db *gorm.DB, where map[string]interface{}) *
db = db.WithContext(ctx)

for k, v := range where {
db.Where(k, v)
db = db.Where(k, v)
}

return db
Expand All @@ -134,7 +134,7 @@ func WithOrder(ctx context.Context, db *gorm.DB, order []string) *gorm.DB {
db = db.WithContext(ctx)

for k, v := range order {
db.Having(k, v)
db = db.Having(k, v)
}

return db
Expand All @@ -148,7 +148,7 @@ func WithHaving(ctx context.Context, db *gorm.DB, having map[string]interface{})
db = db.WithContext(ctx)

for k, v := range having {
db.Having(k, v)
db = db.Having(k, v)
}

return db
Expand Down

0 comments on commit 7471fd7

Please sign in to comment.