|
|
@@ -275,3 +275,23 @@ func (op *Operations) Row() (*TableRow, error) {
|
|
|
func (op *Operations) Count(count *int64) error {
|
|
|
return op.processDB.Count(count).Error
|
|
|
}
|
|
|
+
|
|
|
+func (op *Operations) CheckExist() (bool, error) {
|
|
|
+ var count int64
|
|
|
+ err := op.processDB.Count(&count).Error
|
|
|
+ if err != nil {
|
|
|
+ return false, err
|
|
|
+ }
|
|
|
+
|
|
|
+ return count > 0, nil
|
|
|
+}
|
|
|
+
|
|
|
+func (op *Operations) CheckHasOnlyOne() (bool, error) {
|
|
|
+ var count int64
|
|
|
+ err := op.processDB.Count(&count).Error
|
|
|
+ if err != nil {
|
|
|
+ return false, err
|
|
|
+ }
|
|
|
+
|
|
|
+ return count == 1, nil
|
|
|
+}
|