From b53adf66cb6ac40464893863e5af8c91f5c0c5fb Mon Sep 17 00:00:00 2001 From: xgfone Date: Fri, 21 Jun 2024 17:02:04 +0800 Subject: [PATCH] add the Exist method for Operation --- dml_operation.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dml_operation.go b/dml_operation.go index 2f86eee..debf0be 100644 --- a/dml_operation.go +++ b/dml_operation.go @@ -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 +}