This repository has been archived on 2020-04-12. You can view files and clone it, but cannot push or open issues or pull requests.
tests/testCount.go

28 lines
504 B
Go

package tests
import (
"fmt"
"testing"
"xorm.io/xorm"
)
func count(engine *xorm.Engine, t *testing.T) {
colName := engine.GetColumnMapper().Obj2Table("Departname")
sess := engine.Where("`"+colName+"` = ?", "dev")
total, err := sess.Clone().Count(new(Userinfo))
if err != nil {
t.Error(err)
panic(err)
}
fmt.Printf("Total %d records!!!\n", total)
var users []Userinfo
err = sess.Find(&users)
if err != nil {
t.Error(err)
panic(err)
}
fmt.Printf("Total %d records!!!\n", total)
}