mirror of
https://github.com/tangpanqing/aorm.git
synced 2025-10-13 11:33:55 +08:00
24 lines
422 B
Go
24 lines
422 B
Go
package builder
|
|
|
|
// Exists 存在某记录
|
|
func (b *Builder) Exists() (bool, error) {
|
|
var obj IntStruct
|
|
|
|
err := b.selectCommon("", "1 AS c", nil, "").Limit(0, 1).GetOne(&obj)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
if obj.C.Int64 == 1 {
|
|
return true, nil
|
|
} else {
|
|
return false, nil
|
|
}
|
|
}
|
|
|
|
// DoesntExist 不存在某记录
|
|
func (b *Builder) DoesntExist() (bool, error) {
|
|
isE, err := b.Exists()
|
|
return !isE, err
|
|
}
|