Exist系列方法

判断某个记录是否存在可以使用Exist, 相比GetExist性能更好。

  1. has, err := testEngine.Exist(new(RecordExist))
  2. // SELECT * FROM record_exist LIMIT 1
  1. has, err = testEngine.Exist(&RecordExist{
  2. Name: "test1",
  3. })
  4. // SELECT * FROM record_exist WHERE name = ? LIMIT 1
  1. has, err = testEngine.Where("name = ?", "test1").Exist(&RecordExist{})
  2. // SELECT * FROM record_exist WHERE name = ? LIMIT 1
  1. has, err = testEngine.SQL("select * from record_exist where name = ?", "test1").Exist()
  2. // select * from record_exist where name = ?
  1. has, err = testEngine.Table("record_exist").Exist()
  2. // SELECT * FROM record_exist LIMIT 1
  1. has, err = testEngine.Table("record_exist").Where("name = ?", "test1").Exist()
  2. // SELECT * FROM record_exist WHERE name = ? LIMIT 1