Skip to content

Commit

Permalink
add the Exist method for Operation
Browse files Browse the repository at this point in the history
  • Loading branch information
xgfone committed Jun 21, 2024
1 parent 1f0686a commit b53adf6
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions dml_operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,3 +274,10 @@ func (o Operation[T]) CountDistinct(field string, conds ...op.Condition) (total
err = o.Select(CountDistinct(field)).Where(conds...).Where(op.IsNotDeletedCond).BindRow(&total)
return
}

func (o Operation[T]) Exist(conds ...op.Condition) (exist bool, err error) {
var id int
err = o.Select(op.KeyId.Key).Where(conds...).Where(op.IsNotDeletedCond).BindRow(&id)
exist, err = CheckErrNoRows(err)
return
}

0 comments on commit b53adf6

Please sign in to comment.