session_cols.go 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // Copyright 2017 The Xorm Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package xorm
  5. // Incr provides a query string like "count = count + 1"
  6. func (session *Session) Incr(column string, arg ...interface{}) *Session {
  7. session.Statement.Incr(column, arg...)
  8. return session
  9. }
  10. // Decr provides a query string like "count = count - 1"
  11. func (session *Session) Decr(column string, arg ...interface{}) *Session {
  12. session.Statement.Decr(column, arg...)
  13. return session
  14. }
  15. // SetExpr provides a query string like "column = {expression}"
  16. func (session *Session) SetExpr(column string, expression string) *Session {
  17. session.Statement.SetExpr(column, expression)
  18. return session
  19. }
  20. // Select provides some columns to special
  21. func (session *Session) Select(str string) *Session {
  22. session.Statement.Select(str)
  23. return session
  24. }
  25. // Cols provides some columns to special
  26. func (session *Session) Cols(columns ...string) *Session {
  27. session.Statement.Cols(columns...)
  28. return session
  29. }
  30. // AllCols ask all columns
  31. func (session *Session) AllCols() *Session {
  32. session.Statement.AllCols()
  33. return session
  34. }
  35. // MustCols specify some columns must use even if they are empty
  36. func (session *Session) MustCols(columns ...string) *Session {
  37. session.Statement.MustCols(columns...)
  38. return session
  39. }
  40. // UseBool automatically retrieve condition according struct, but
  41. // if struct has bool field, it will ignore them. So use UseBool
  42. // to tell system to do not ignore them.
  43. // If no parameters, it will use all the bool field of struct, or
  44. // it will use parameters's columns
  45. func (session *Session) UseBool(columns ...string) *Session {
  46. session.Statement.UseBool(columns...)
  47. return session
  48. }
  49. // Distinct use for distinct columns. Caution: when you are using cache,
  50. // distinct will not be cached because cache system need id,
  51. // but distinct will not provide id
  52. func (session *Session) Distinct(columns ...string) *Session {
  53. session.Statement.Distinct(columns...)
  54. return session
  55. }
  56. // Omit Only not use the parameters as select or update columns
  57. func (session *Session) Omit(columns ...string) *Session {
  58. session.Statement.Omit(columns...)
  59. return session
  60. }
  61. // Nullable Set null when column is zero-value and nullable for update
  62. func (session *Session) Nullable(columns ...string) *Session {
  63. session.Statement.Nullable(columns...)
  64. return session
  65. }
  66. // NoAutoTime means do not automatically give created field and updated field
  67. // the current time on the current session temporarily
  68. func (session *Session) NoAutoTime() *Session {
  69. session.Statement.UseAutoTime = false
  70. return session
  71. }