You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
2.6 KiB

  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. }