github.com/aavshr/aws-sdk-go@v1.41.3/service/dynamodb/expression/condition.go (about)

     1  package expression
     2  
     3  import (
     4  	"fmt"
     5  	"strings"
     6  )
     7  
     8  // conditionMode specifies the types of the struct conditionBuilder,
     9  // representing the different types of Conditions (i.e. And, Or, Between, ...)
    10  type conditionMode int
    11  
    12  const (
    13  	// unsetCond catches errors for unset ConditionBuilder structs
    14  	unsetCond conditionMode = iota
    15  	// equalCond represents the Equals Condition
    16  	equalCond
    17  	// notEqualCond represents the Not Equals Condition
    18  	notEqualCond
    19  	// lessThanCond represents the LessThan Condition
    20  	lessThanCond
    21  	// lessThanEqualCond represents the LessThanOrEqual Condition
    22  	lessThanEqualCond
    23  	// greaterThanCond represents the GreaterThan Condition
    24  	greaterThanCond
    25  	// greaterThanEqualCond represents the GreaterThanEqual Condition
    26  	greaterThanEqualCond
    27  	// andCond represents the Logical And Condition
    28  	andCond
    29  	// orCond represents the Logical Or Condition
    30  	orCond
    31  	// notCond represents the Logical Not Condition
    32  	notCond
    33  	// betweenCond represents the Between Condition
    34  	betweenCond
    35  	// inCond represents the In Condition
    36  	inCond
    37  	// attrExistsCond represents the Attribute Exists Condition
    38  	attrExistsCond
    39  	// attrNotExistsCond represents the Attribute Not Exists Condition
    40  	attrNotExistsCond
    41  	// attrTypeCond represents the Attribute Type Condition
    42  	attrTypeCond
    43  	// beginsWithCond represents the Begins With Condition
    44  	beginsWithCond
    45  	// containsCond represents the Contains Condition
    46  	containsCond
    47  )
    48  
    49  // DynamoDBAttributeType specifies the type of an DynamoDB item attribute. This
    50  // enum is used in the AttributeType() function in order to be explicit about
    51  // the DynamoDB type that is being checked and ensure compile time checks.
    52  // More Informatin at http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions
    53  type DynamoDBAttributeType string
    54  
    55  const (
    56  	// String represents the DynamoDB String type
    57  	String DynamoDBAttributeType = "S"
    58  	// StringSet represents the DynamoDB String Set type
    59  	StringSet = "SS"
    60  	// Number represents the DynamoDB Number type
    61  	Number = "N"
    62  	// NumberSet represents the DynamoDB Number Set type
    63  	NumberSet = "NS"
    64  	// Binary represents the DynamoDB Binary type
    65  	Binary = "B"
    66  	// BinarySet represents the DynamoDB Binary Set type
    67  	BinarySet = "BS"
    68  	// Boolean represents the DynamoDB Boolean type
    69  	Boolean = "BOOL"
    70  	// Null represents the DynamoDB Null type
    71  	Null = "NULL"
    72  	// List represents the DynamoDB List type
    73  	List = "L"
    74  	// Map represents the DynamoDB Map type
    75  	Map = "M"
    76  )
    77  
    78  // ConditionBuilder represents Condition Expressions and Filter Expressions
    79  // in DynamoDB. ConditionBuilders are one of the building blocks of the Builder
    80  // struct. Since Filter Expressions support all the same functions and formats
    81  // as Condition Expressions, ConditionBuilders represents both types of
    82  // Expressions.
    83  // More Information at: http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.ConditionExpressions.html
    84  // More Information on Filter Expressions: http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Query.html#Query.FilterExpression
    85  type ConditionBuilder struct {
    86  	operandList   []OperandBuilder
    87  	conditionList []ConditionBuilder
    88  	mode          conditionMode
    89  }
    90  
    91  // Equal returns a ConditionBuilder representing the equality clause of the two
    92  // argument OperandBuilders. The resulting ConditionBuilder can be used as a
    93  // part of other Condition Expressions or as an argument to the WithCondition()
    94  // method for the Builder struct.
    95  //
    96  // Example:
    97  //
    98  //     // condition represents the equal clause of the item attribute "foo" and
    99  //     // the value 5
   100  //     condition := expression.Equal(expression.Name("foo"), expression.Value(5))
   101  //
   102  //     // Used in another Condition Expression
   103  //     anotherCondition := expression.Not(condition)
   104  //     // Used to make an Builder
   105  //     builder := expression.NewBuilder().WithCondition(condition)
   106  //
   107  // Expression Equivalent:
   108  //
   109  //     expression.Equal(expression.Name("foo"), expression.Value(5))
   110  //     // Let :five be an ExpressionAttributeValue representing the value 5
   111  //     "foo = :five"
   112  func Equal(left, right OperandBuilder) ConditionBuilder {
   113  	return ConditionBuilder{
   114  		operandList: []OperandBuilder{left, right},
   115  		mode:        equalCond,
   116  	}
   117  }
   118  
   119  // Equal returns a ConditionBuilder representing the equality clause of the two
   120  // argument OperandBuilders. The resulting ConditionBuilder can be used as a
   121  // part of other Condition Expressions or as an argument to the WithCondition()
   122  // method for the Builder struct.
   123  //
   124  // Example:
   125  //
   126  //     // condition represents the equal clause of the item attribute "foo" and
   127  //     // the value 5
   128  //     condition := expression.Name("foo").Equal(expression.Value(5))
   129  //
   130  //     // Used in another Condition Expression
   131  //     anotherCondition := expression.Not(condition)
   132  //     // Used to make an Builder
   133  //     builder := expression.NewBuilder().WithCondition(condition)
   134  //
   135  // Expression Equivalent:
   136  //
   137  //     expression.Name("foo").Equal(expression.Value(5))
   138  //     // Let :five be an ExpressionAttributeValue representing the value 5
   139  //     "foo = :five"
   140  func (nb NameBuilder) Equal(right OperandBuilder) ConditionBuilder {
   141  	return Equal(nb, right)
   142  }
   143  
   144  // Equal returns a ConditionBuilder representing the equality clause of the two
   145  // argument OperandBuilders. The resulting ConditionBuilder can be used as a
   146  // part of other Condition Expressions or as an argument to the WithCondition()
   147  // method for the Builder struct.
   148  //
   149  // Example:
   150  //
   151  //     // condition represents the equal clause of the item attribute "foo" and
   152  //     // the value 5
   153  //     condition := expression.Value(5).Equal(expression.Name("foo"))
   154  //
   155  //     // Used in another Condition Expression
   156  //     anotherCondition := expression.Not(condition)
   157  //     // Used to make an Builder
   158  //     builder := expression.NewBuilder().WithCondition(condition)
   159  //
   160  // Expression Equivalent:
   161  //
   162  //     expression.Value(5).Equal(expression.Name("foo"))
   163  //     // Let :five be an ExpressionAttributeValue representing the value 5
   164  //     ":five = foo"
   165  func (vb ValueBuilder) Equal(right OperandBuilder) ConditionBuilder {
   166  	return Equal(vb, right)
   167  }
   168  
   169  // Equal returns a ConditionBuilder representing the equality clause of the two
   170  // argument OperandBuilders. The resulting ConditionBuilder can be used as a
   171  // part of other Condition Expressions or as an argument to the WithCondition()
   172  // method for the Builder struct.
   173  //
   174  // Example:
   175  //
   176  //     // condition represents the equal clause of the size of the item
   177  //     // attribute "foo" and the value 5
   178  //     condition := expression.Size(expression.Name("foo")).Equal(expression.Value(5))
   179  //
   180  //     // Used in another Condition Expression
   181  //     anotherCondition := expression.Not(condition)
   182  //     // Used to make an Builder
   183  //     builder := expression.NewBuilder().WithCondition(condition)
   184  //
   185  // Expression Equivalent:
   186  //
   187  //     expression.Size(expression.Name("foo")).Equal(expression.Value(5))
   188  //     // Let :five be an ExpressionAttributeValue representing the value 5
   189  //     "size (foo) = :five"
   190  func (sb SizeBuilder) Equal(right OperandBuilder) ConditionBuilder {
   191  	return Equal(sb, right)
   192  }
   193  
   194  // NotEqual returns a ConditionBuilder representing the not equal clause of the
   195  // two argument OperandBuilders. The resulting ConditionBuilder can be used as a
   196  // part of other Condition Expressions or as an argument to the WithCondition()
   197  // method for the Builder struct.
   198  //
   199  // Example:
   200  //
   201  //     // condition represents the not equal clause of the item attribute "foo"
   202  //     // and the value 5
   203  //     condition := expression.NotEqual(expression.Name("foo"), expression.Value(5))
   204  //
   205  //     // Used in another Condition Expression
   206  //     anotherCondition := expression.Not(condition)
   207  //     // Used to make an Builder
   208  //     builder := expression.NewBuilder().WithCondition(condition)
   209  //
   210  // Expression Equivalent:
   211  //
   212  //     expression.NotEqual(expression.Name("foo"), expression.Value(5))
   213  //     // Let :five be an ExpressionAttributeValue representing the value 5
   214  //     "foo <> :five"
   215  func NotEqual(left, right OperandBuilder) ConditionBuilder {
   216  	return ConditionBuilder{
   217  		operandList: []OperandBuilder{left, right},
   218  		mode:        notEqualCond,
   219  	}
   220  }
   221  
   222  // NotEqual returns a ConditionBuilder representing the not equal clause of the
   223  // two argument OperandBuilders. The resulting ConditionBuilder can be used as a
   224  // part of other Condition Expressions or as an argument to the WithCondition()
   225  // method for the Builder struct.
   226  //
   227  // Example:
   228  //
   229  //     // condition represents the not equal clause of the item attribute "foo"
   230  //     // and the value 5
   231  //     condition := expression.Name("foo").NotEqual(expression.Value(5))
   232  //
   233  //     // Used in another Condition Expression
   234  //     anotherCondition := expression.Not(condition)
   235  //     // Used to make an Builder
   236  //     builder := expression.NewBuilder().WithCondition(condition)
   237  //
   238  // Expression Equivalent:
   239  //
   240  //     expression.Name("foo").NotEqual(expression.Value(5))
   241  //     // Let :five be an ExpressionAttributeValue representing the value 5
   242  //     "foo <> :five"
   243  func (nb NameBuilder) NotEqual(right OperandBuilder) ConditionBuilder {
   244  	return NotEqual(nb, right)
   245  }
   246  
   247  // NotEqual returns a ConditionBuilder representing the not equal clause of the
   248  // two argument OperandBuilders. The resulting ConditionBuilder can be used as a
   249  // part of other Condition Expressions or as an argument to the WithCondition()
   250  // method for the Builder struct.
   251  //
   252  // Example:
   253  //
   254  //     // condition represents the not equal clause of the item attribute "foo"
   255  //     // and the value 5
   256  //     condition := expression.Value(5).NotEqual(expression.Name("foo"))
   257  //
   258  //     // Used in another Condition Expression
   259  //     anotherCondition := expression.Not(condition)
   260  //     // Used to make an Builder
   261  //     builder := expression.NewBuilder().WithCondition(condition)
   262  //
   263  // Expression Equivalent:
   264  //
   265  //     expression.Value(5).NotEqual(expression.Name("foo"))
   266  //     // Let :five be an ExpressionAttributeValue representing the value 5
   267  //     ":five <> foo"
   268  func (vb ValueBuilder) NotEqual(right OperandBuilder) ConditionBuilder {
   269  	return NotEqual(vb, right)
   270  }
   271  
   272  // NotEqual returns a ConditionBuilder representing the not equal clause of the
   273  // two argument OperandBuilders. The resulting ConditionBuilder can be used as a
   274  // part of other Condition Expressions or as an argument to the WithCondition()
   275  // method for the Builder struct.
   276  //
   277  // Example:
   278  //
   279  //     // condition represents the not equal clause of the size of the item
   280  //     // attribute "foo" and the value 5
   281  //     condition := expression.Size(expression.Name("foo")).NotEqual(expression.Value(5))
   282  //
   283  //     // Used in another Condition Expression
   284  //     anotherCondition := expression.Not(condition)
   285  //     // Used to make an Builder
   286  //     builder := expression.NewBuilder().WithCondition(condition)
   287  //
   288  // Expression Equivalent:
   289  //
   290  //     expression.Size(expression.Name("foo")).NotEqual(expression.Value(5))
   291  //     // Let :five be an ExpressionAttributeValue representing the value 5
   292  //     "size (foo) <> :five"
   293  func (sb SizeBuilder) NotEqual(right OperandBuilder) ConditionBuilder {
   294  	return NotEqual(sb, right)
   295  }
   296  
   297  // LessThan returns a ConditionBuilder representing the less than clause of the
   298  // two argument OperandBuilders. The resulting ConditionBuilder can be used as a
   299  // part of other Condition Expressions or as an argument to the WithCondition()
   300  // method for the Builder struct.
   301  //
   302  // Example:
   303  //
   304  //     // condition represents the less than clause of the item attribute "foo"
   305  //     // and the value 5
   306  //     condition := expression.LessThan(expression.Name("foo"), expression.Value(5))
   307  //
   308  //     // Used in another Condition Expression
   309  //     anotherCondition := expression.Not(condition)
   310  //     // Used to make an Builder
   311  //     builder := expression.NewBuilder().WithCondition(condition)
   312  //
   313  // Expression Equivalent:
   314  //
   315  //     expression.LessThan(expression.Name("foo"), expression.Value(5))
   316  //     // Let :five be an ExpressionAttributeValue representing the value 5
   317  //     "foo < :five"
   318  func LessThan(left, right OperandBuilder) ConditionBuilder {
   319  	return ConditionBuilder{
   320  		operandList: []OperandBuilder{left, right},
   321  		mode:        lessThanCond,
   322  	}
   323  }
   324  
   325  // LessThan returns a ConditionBuilder representing the less than clause of the
   326  // two argument OperandBuilders. The resulting ConditionBuilder can be used as a
   327  // part of other Condition Expressions or as an argument to the WithCondition()
   328  // method for the Builder struct.
   329  //
   330  // Example:
   331  //
   332  //     // condition represents the less than clause of the item attribute "foo"
   333  //     // and the value 5
   334  //     condition := expression.Name("foo").LessThan(expression.Value(5))
   335  //
   336  //     // Used in another Condition Expression
   337  //     anotherCondition := expression.Not(condition)
   338  //     // Used to make an Builder
   339  //     builder := expression.NewBuilder().WithCondition(condition)
   340  //
   341  // Expression Equivalent:
   342  //
   343  //     expression.Name("foo").LessThan(expression.Value(5))
   344  //     // Let :five be an ExpressionAttributeValue representing the value 5
   345  //     "foo < :five"
   346  func (nb NameBuilder) LessThan(right OperandBuilder) ConditionBuilder {
   347  	return LessThan(nb, right)
   348  }
   349  
   350  // LessThan returns a ConditionBuilder representing the less than clause of the
   351  // two argument OperandBuilders. The resulting ConditionBuilder can be used as a
   352  // part of other Condition Expressions or as an argument to the WithCondition()
   353  // method for the Builder struct.
   354  //
   355  // Example:
   356  //
   357  //     // condition represents the less than clause of the item attribute "foo"
   358  //     // and the value 5
   359  //     condition := expression.Value(5).LessThan(expression.Name("foo"))
   360  //
   361  //     // Used in another Condition Expression
   362  //     anotherCondition := expression.Not(condition)
   363  //     // Used to make an Builder
   364  //     builder := expression.NewBuilder().WithCondition(condition)
   365  //
   366  // Expression Equivalent:
   367  //
   368  //     expression.Value(5).LessThan(expression.Name("foo"))
   369  //     // Let :five be an ExpressionAttributeValue representing the value 5
   370  //     ":five < foo"
   371  func (vb ValueBuilder) LessThan(right OperandBuilder) ConditionBuilder {
   372  	return LessThan(vb, right)
   373  }
   374  
   375  // LessThan returns a ConditionBuilder representing the less than clause of the
   376  // two argument OperandBuilders. The resulting ConditionBuilder can be used as a
   377  // part of other Condition Expressions or as an argument to the WithCondition()
   378  // method for the Builder struct.
   379  //
   380  // Example:
   381  //
   382  //     // condition represents the less than clause of the size of the item
   383  //     // attribute "foo" and the value 5
   384  //     condition := expression.Size(expression.Name("foo")).LessThan(expression.Value(5))
   385  //
   386  //     // Used in another Condition Expression
   387  //     anotherCondition := expression.Not(condition)
   388  //     // Used to make an Builder
   389  //     builder := expression.NewBuilder().WithCondition(condition)
   390  //
   391  // Expression Equivalent:
   392  //
   393  //     expression.Size(expression.Name("foo")).LessThan(expression.Value(5))
   394  //     // Let :five be an ExpressionAttributeValue representing the value 5
   395  //     "size (foo) < :five"
   396  func (sb SizeBuilder) LessThan(right OperandBuilder) ConditionBuilder {
   397  	return LessThan(sb, right)
   398  }
   399  
   400  // LessThanEqual returns a ConditionBuilder representing the less than equal to
   401  // clause of the two argument OperandBuilders. The resulting ConditionBuilder
   402  // can be used as a part of other Condition Expressions or as an argument to the
   403  // WithCondition() method for the Builder struct.
   404  //
   405  // Example:
   406  //
   407  //     // condition represents the less than equal to clause of the item
   408  //     // attribute "foo" and the value 5
   409  //     condition := expression.LessThanEqual(expression.Name("foo"), expression.Value(5))
   410  //
   411  //     // Used in another Condition Expression
   412  //     anotherCondition := expression.Not(condition)
   413  //     // Used to make an Builder
   414  //     builder := expression.NewBuilder().WithCondition(condition)
   415  //
   416  // Expression Equivalent:
   417  //
   418  //     expression.LessThanEqual(expression.Name("foo"), expression.Value(5))
   419  //     // Let :five be an ExpressionAttributeValue representing the value 5
   420  //     "foo <= :five"
   421  func LessThanEqual(left, right OperandBuilder) ConditionBuilder {
   422  	return ConditionBuilder{
   423  		operandList: []OperandBuilder{left, right},
   424  		mode:        lessThanEqualCond,
   425  	}
   426  }
   427  
   428  // LessThanEqual returns a ConditionBuilder representing the less than equal to
   429  // clause of the two argument OperandBuilders. The resulting ConditionBuilder
   430  // can be used as a part of other Condition Expressions or as an argument to the
   431  // WithCondition() method for the Builder struct.
   432  //
   433  // Example:
   434  //
   435  //     // condition represents the less than equal to clause of the item
   436  //     // attribute "foo" and the value 5
   437  //     condition := expression.Name("foo").LessThanEqual(expression.Value(5))
   438  //
   439  //     // Used in another Condition Expression
   440  //     anotherCondition := expression.Not(condition)
   441  //     // Used to make an Builder
   442  //     builder := expression.NewBuilder().WithCondition(condition)
   443  //
   444  // Expression Equivalent:
   445  //
   446  //     expression.Name("foo").LessThanEqual(expression.Value(5))
   447  //     // Let :five be an ExpressionAttributeValue representing the value 5
   448  //     "foo <= :five"
   449  func (nb NameBuilder) LessThanEqual(right OperandBuilder) ConditionBuilder {
   450  	return LessThanEqual(nb, right)
   451  }
   452  
   453  // LessThanEqual returns a ConditionBuilder representing the less than equal to
   454  // clause of the two argument OperandBuilders. The resulting ConditionBuilder
   455  // can be used as a part of other Condition Expressions or as an argument to the
   456  // WithCondition() method for the Builder struct.
   457  //
   458  // Example:
   459  //
   460  //     // condition represents the less than equal to clause of the item
   461  //     // attribute "foo" and the value 5
   462  //     condition := expression.Value(5).LessThanEqual(expression.Name("foo"))
   463  //
   464  //     // Used in another Condition Expression
   465  //     anotherCondition := expression.Not(condition)
   466  //     // Used to make an Builder
   467  //     builder := expression.NewBuilder().WithCondition(condition)
   468  //
   469  // Expression Equivalent:
   470  //
   471  //     expression.Value(5).LessThanEqual(expression.Name("foo"))
   472  //     // Let :five be an ExpressionAttributeValue representing the value 5
   473  //     ":five <= foo"
   474  func (vb ValueBuilder) LessThanEqual(right OperandBuilder) ConditionBuilder {
   475  	return LessThanEqual(vb, right)
   476  }
   477  
   478  // LessThanEqual returns a ConditionBuilder representing the less than equal to
   479  // clause of the two argument OperandBuilders. The resulting ConditionBuilder
   480  // can be used as a part of other Condition Expressions or as an argument to the
   481  // WithCondition() method for the Builder struct.
   482  //
   483  // Example:
   484  //
   485  //     // condition represents the less than equal to clause of the size of the
   486  //     // item attribute "foo" and the value 5
   487  //     condition := expression.Size(expression.Name("foo")).LessThanEqual(expression.Value(5))
   488  //
   489  //     // Used in another Condition Expression
   490  //     anotherCondition := expression.Not(condition)
   491  //     // Used to make an Builder
   492  //     builder := expression.NewBuilder().WithCondition(condition)
   493  //
   494  // Expression Equivalent:
   495  //
   496  //     expression.Size(expression.Name("foo")).LessThanEqual(expression.Value(5))
   497  //     // Let :five be an ExpressionAttributeValue representing the value 5
   498  //     "size (foo) <= :five"
   499  func (sb SizeBuilder) LessThanEqual(right OperandBuilder) ConditionBuilder {
   500  	return LessThanEqual(sb, right)
   501  }
   502  
   503  // GreaterThan returns a ConditionBuilder representing the greater than clause
   504  // of the two argument OperandBuilders. The resulting ConditionBuilder can be
   505  // used as a part of other Condition Expressions or as an argument to the
   506  // WithCondition() method for the Builder struct.
   507  //
   508  // Example:
   509  //
   510  //     // condition represents the greater than clause of the item attribute
   511  //     // "foo" and the value 5
   512  //     condition := expression.GreaterThan(expression.Name("foo"), expression.Value(5))
   513  //
   514  //     // Used in another Condition Expression
   515  //     anotherCondition := expression.Not(condition)
   516  //     // Used to make an Builder
   517  //     builder := expression.NewBuilder().WithCondition(condition)
   518  //
   519  // Expression Equivalent:
   520  //
   521  //     expression.GreaterThan(expression.Name("foo"), expression.Value(5))
   522  //     // Let :five be an ExpressionAttributeValue representing the value 5
   523  //     "foo > :five"
   524  func GreaterThan(left, right OperandBuilder) ConditionBuilder {
   525  	return ConditionBuilder{
   526  		operandList: []OperandBuilder{left, right},
   527  		mode:        greaterThanCond,
   528  	}
   529  }
   530  
   531  // GreaterThan returns a ConditionBuilder representing the greater than clause
   532  // of the two argument OperandBuilders. The resulting ConditionBuilder can be
   533  // used as a part of other Condition Expressions or as an argument to the
   534  // WithCondition() method for the Builder struct.
   535  //
   536  // Example:
   537  //
   538  //     // condition represents the greater than clause of the item attribute
   539  //     // "foo" and the value 5
   540  //     condition := expression.Name("foo").GreaterThan(expression.Value(5))
   541  //
   542  //     // Used in another Condition Expression
   543  //     anotherCondition := expression.Not(condition)
   544  //     // Used to make an Builder
   545  //     builder := expression.NewBuilder().WithCondition(condition)
   546  //
   547  // Expression Equivalent:
   548  //
   549  //     expression.Name("foo").GreaterThan(expression.Value(5))
   550  //     // Let :five be an ExpressionAttributeValue representing the value 5
   551  //     "foo > :five"
   552  func (nb NameBuilder) GreaterThan(right OperandBuilder) ConditionBuilder {
   553  	return GreaterThan(nb, right)
   554  }
   555  
   556  // GreaterThan returns a ConditionBuilder representing the greater than clause
   557  // of the two argument OperandBuilders. The resulting ConditionBuilder can be
   558  // used as a part of other Condition Expressions or as an argument to the
   559  // WithCondition() method for the Builder struct.
   560  //
   561  // Example:
   562  //
   563  //     // condition represents the greater than clause of the item attribute
   564  //     // "foo" and the value 5
   565  //     condition := expression.Value(5).GreaterThan(expression.Name("foo"))
   566  //
   567  //     // Used in another Condition Expression
   568  //     anotherCondition := expression.Not(condition)
   569  //     // Used to make an Builder
   570  //     builder := expression.NewBuilder().WithCondition(condition)
   571  //
   572  // Expression Equivalent:
   573  //
   574  //     expression.Value(5).GreaterThan(expression.Name("foo"))
   575  //     // Let :five be an ExpressionAttributeValue representing the value 5
   576  //     ":five > foo"
   577  func (vb ValueBuilder) GreaterThan(right OperandBuilder) ConditionBuilder {
   578  	return GreaterThan(vb, right)
   579  }
   580  
   581  // GreaterThan returns a ConditionBuilder representing the greater than
   582  // clause of the two argument OperandBuilders. The resulting ConditionBuilder
   583  // can be used as a part of other Condition Expressions or as an argument to the
   584  // WithCondition() method for the Builder struct.
   585  //
   586  // Example:
   587  //
   588  //     // condition represents the greater than clause of the size of the item
   589  //     // attribute "foo" and the value 5
   590  //     condition := expression.Size(expression.Name("foo")).GreaterThan(expression.Value(5))
   591  //
   592  //     // Used in another Condition Expression
   593  //     anotherCondition := expression.Not(condition)
   594  //     // Used to make an Builder
   595  //     builder := expression.NewBuilder().WithCondition(condition)
   596  //
   597  // Expression Equivalent:
   598  //
   599  //     expression.Size(expression.Name("foo")).GreaterThan(expression.Value(5))
   600  //     // Let :five be an ExpressionAttributeValue representing the value 5
   601  //     "size (foo) > :five"
   602  func (sb SizeBuilder) GreaterThan(right OperandBuilder) ConditionBuilder {
   603  	return GreaterThan(sb, right)
   604  }
   605  
   606  // GreaterThanEqual returns a ConditionBuilder representing the greater than
   607  // equal to clause of the two argument OperandBuilders. The resulting
   608  // ConditionBuilder can be used as a part of other Condition Expressions or as
   609  // an argument to the WithCondition() method for the Builder struct.
   610  //
   611  // Example:
   612  //
   613  //     // condition represents the greater than equal to clause of the item
   614  //     // attribute "foo" and the value 5
   615  //     condition := expression.GreaterThanEqual(expression.Name("foo"), expression.Value(5))
   616  //
   617  //     // Used in another Condition Expression
   618  //     anotherCondition := expression.Not(condition)
   619  //     // Used to make an Builder
   620  //     builder := expression.NewBuilder().WithCondition(condition)
   621  //
   622  // Expression Equivalent:
   623  //
   624  //     expression.GreaterThanEqual(expression.Name("foo"), expression.Value(5))
   625  //     // Let :five be an ExpressionAttributeValue representing the value 5
   626  //     "foo >= :five"
   627  func GreaterThanEqual(left, right OperandBuilder) ConditionBuilder {
   628  	return ConditionBuilder{
   629  		operandList: []OperandBuilder{left, right},
   630  		mode:        greaterThanEqualCond,
   631  	}
   632  }
   633  
   634  // GreaterThanEqual returns a ConditionBuilder representing the greater than
   635  // equal to clause of the two argument OperandBuilders. The resulting
   636  // ConditionBuilder can be used as a part of other Condition Expressions or as
   637  // an argument to the WithCondition() method for the Builder struct.
   638  //
   639  // Example:
   640  //
   641  //     // condition represents the greater than equal to clause of the item
   642  //     // attribute "foo" and the value 5
   643  //     condition := expression.Name("foo").GreaterThanEqual(expression.Value(5))
   644  //
   645  //     // Used in another Condition Expression
   646  //     anotherCondition := expression.Not(condition)
   647  //     // Used to make an Builder
   648  //     builder := expression.NewBuilder().WithCondition(condition)
   649  //
   650  // Expression Equivalent:
   651  //
   652  //     expression.Name("foo").GreaterThanEqual(expression.Value(5))
   653  //     // Let :five be an ExpressionAttributeValue representing the value 5
   654  //     "foo >= :five"
   655  func (nb NameBuilder) GreaterThanEqual(right OperandBuilder) ConditionBuilder {
   656  	return GreaterThanEqual(nb, right)
   657  }
   658  
   659  // GreaterThanEqual returns a ConditionBuilder representing the greater than
   660  // equal to clause of the two argument OperandBuilders. The resulting
   661  // ConditionBuilder can be used as a part of other Condition Expressions or as
   662  // an argument to the WithCondition() method for the Builder struct.
   663  //
   664  // Example:
   665  //
   666  //     // condition represents the greater than equal to clause of the item
   667  //     // attribute "foo" and the value 5
   668  //     condition := expression.Value(5).GreaterThanEqual(expression.Name("foo"))
   669  //
   670  //     // Used in another Condition Expression
   671  //     anotherCondition := expression.Not(condition)
   672  //     // Used to make an Builder
   673  //     builder := expression.NewBuilder().WithCondition(condition)
   674  //
   675  // Expression Equivalent:
   676  //
   677  //     expression.Value(5).GreaterThanEqual(expression.Name("foo"))
   678  //     // Let :five be an ExpressionAttributeValue representing the value 5
   679  //     ":five >= foo"
   680  func (vb ValueBuilder) GreaterThanEqual(right OperandBuilder) ConditionBuilder {
   681  	return GreaterThanEqual(vb, right)
   682  }
   683  
   684  // GreaterThanEqual returns a ConditionBuilder representing the greater than
   685  // equal to clause of the two argument OperandBuilders. The resulting
   686  // ConditionBuilder can be used as a part of other Condition Expressions or as
   687  // an argument to the WithCondition() method for the Builder struct.
   688  //
   689  // Example:
   690  //
   691  //     // condition represents the greater than equal to clause of the size of
   692  //     // the item attribute "foo" and the value 5
   693  //     condition := expression.Size(expression.Name("foo")).GreaterThanEqual(expression.Value(5))
   694  //
   695  //     // Used in another Condition Expression
   696  //     anotherCondition := expression.Not(condition)
   697  //     // Used to make an Builder
   698  //     builder := expression.NewBuilder().WithCondition(condition)
   699  //
   700  // Expression Equivalent:
   701  //
   702  //     expression.Size(expression.Name("foo")).GreaterThanEqual(expression.Value(5))
   703  //     // Let :five be an ExpressionAttributeValue representing the value 5
   704  //     "size (foo) >= :five"
   705  func (sb SizeBuilder) GreaterThanEqual(right OperandBuilder) ConditionBuilder {
   706  	return GreaterThanEqual(sb, right)
   707  }
   708  
   709  // And returns a ConditionBuilder representing the logical AND clause of the
   710  // argument ConditionBuilders. The resulting ConditionBuilder can be used as a
   711  // part of other Condition Expressions or as an argument to the WithCondition()
   712  // method for the Builder struct. Note that And() can take a variadic number of
   713  // ConditionBuilders as arguments.
   714  //
   715  // Example:
   716  //
   717  //     // condition represents the condition where the item attribute "Name" is
   718  //     // equal to value "Generic Name" AND the item attribute "Age" is less
   719  //     // than value 40
   720  //     condition := expression.And(expression.Name("Name").Equal(expression.Value("Generic Name")), expression.Name("Age").LessThan(expression.Value(40)))
   721  //
   722  //     // Used in another Condition Expression
   723  //     anotherCondition := expression.Not(condition)
   724  //     // Used to make an Builder
   725  //     builder := expression.NewBuilder().WithCondition(condition)
   726  //
   727  // Expression Equivalent:
   728  //
   729  //     expression.And(expression.Name("Name").Equal(expression.Value("Generic Name")), expression.Name("Age").LessThan(expression.Value(40)))
   730  //     // Let #NAME, :name, and :forty be ExpressionAttributeName and
   731  //     // ExpressionAttributeValues representing the item attribute "Name", the
   732  //     // value "Generic Name", and the value 40
   733  //     "(#NAME = :name) AND (Age < :forty)"
   734  func And(left, right ConditionBuilder, other ...ConditionBuilder) ConditionBuilder {
   735  	other = append([]ConditionBuilder{left, right}, other...)
   736  	return ConditionBuilder{
   737  		conditionList: other,
   738  		mode:          andCond,
   739  	}
   740  }
   741  
   742  // And returns a ConditionBuilder representing the logical AND clause of the
   743  // argument ConditionBuilders. The resulting ConditionBuilder can be used as a
   744  // part of other Condition Expressions or as an argument to the WithCondition()
   745  // method for the Builder struct. Note that And() can take a variadic number of
   746  // ConditionBuilders as arguments.
   747  //
   748  // Example:
   749  //
   750  //     // condition represents the condition where the item attribute "Name" is
   751  //     // equal to value "Generic Name" AND the item attribute "Age" is less
   752  //     // than value 40
   753  //     condition := expression.Name("Name").Equal(expression.Value("Generic Name")).And(expression.Name("Age").LessThan(expression.Value(40)))
   754  //
   755  //     // Used in another Condition Expression
   756  //     anotherCondition := expression.Not(condition)
   757  //     // Used to make an Builder
   758  //     builder := expression.NewBuilder().WithCondition(condition)
   759  //
   760  // Expression Equivalent:
   761  //
   762  //     expression.Name("Name").Equal(expression.Value("Generic Name")).And(expression.Name("Age").LessThan(expression.Value(40)))
   763  //     // Let #NAME, :name, and :forty be ExpressionAttributeName and
   764  //     // ExpressionAttributeValues representing the item attribute "Name", the
   765  //     // value "Generic Name", and the value 40
   766  //     "(#NAME = :name) AND (Age < :forty)"
   767  func (cb ConditionBuilder) And(right ConditionBuilder, other ...ConditionBuilder) ConditionBuilder {
   768  	return And(cb, right, other...)
   769  }
   770  
   771  // Or returns a ConditionBuilder representing the logical OR clause of the
   772  // argument ConditionBuilders. The resulting ConditionBuilder can be used as a
   773  // part of other Condition Expressions or as an argument to the WithCondition()
   774  // method for the Builder struct. Note that Or() can take a variadic number of
   775  // ConditionBuilders as arguments.
   776  //
   777  // Example:
   778  //
   779  //     // condition represents the condition where the item attribute "Price" is
   780  //     // less than the value 100 OR the item attribute "Rating" is greater than
   781  //     // the value 8
   782  //     condition := expression.Or(expression.Name("Price").Equal(expression.Value(100)), expression.Name("Rating").LessThan(expression.Value(8)))
   783  //
   784  //     // Used in another Condition Expression
   785  //     anotherCondition := expression.Not(condition)
   786  //     // Used to make an Builder
   787  //     builder := expression.NewBuilder().WithCondition(condition)
   788  //
   789  // Expression Equivalent:
   790  //
   791  //     expression.Or(expression.Name("Price").Equal(expression.Value(100)), expression.Name("Rating").LessThan(expression.Value(8)))
   792  //     // Let :price and :rating be ExpressionAttributeValues representing the
   793  //     // the value 100 and value 8 respectively
   794  //     "(Price < :price) OR (Rating > :rating)"
   795  func Or(left, right ConditionBuilder, other ...ConditionBuilder) ConditionBuilder {
   796  	other = append([]ConditionBuilder{left, right}, other...)
   797  	return ConditionBuilder{
   798  		conditionList: other,
   799  		mode:          orCond,
   800  	}
   801  }
   802  
   803  // Or returns a ConditionBuilder representing the logical OR clause of the
   804  // argument ConditionBuilders. The resulting ConditionBuilder can be used as a
   805  // part of other Condition Expressions or as an argument to the WithCondition()
   806  // method for the Builder struct. Note that Or() can take a variadic number of
   807  // ConditionBuilders as arguments.
   808  //
   809  // Example:
   810  //
   811  //     // condition represents the condition where the item attribute "Price" is
   812  //     // less than the value 100 OR the item attribute "Rating" is greater than
   813  //     // the value 8
   814  //     condition := expression.Name("Price").Equal(expression.Value(100)).Or(expression.Name("Rating").LessThan(expression.Value(8)))
   815  //
   816  //     // Used in another Condition Expression
   817  //     anotherCondition := expression.Not(condition)
   818  //     // Used to make an Builder
   819  //     builder := expression.NewBuilder().WithCondition(condition)
   820  //
   821  // Expression Equivalent:
   822  //
   823  //     expression.Name("Price").Equal(expression.Value(100)).Or(expression.Name("Rating").LessThan(expression.Value(8)))
   824  //     // Let :price and :rating be ExpressionAttributeValues representing the
   825  //     // the value 100 and value 8 respectively
   826  //     "(Price < :price) OR (Rating > :rating)"
   827  func (cb ConditionBuilder) Or(right ConditionBuilder, other ...ConditionBuilder) ConditionBuilder {
   828  	return Or(cb, right, other...)
   829  }
   830  
   831  // Not returns a ConditionBuilder representing the logical NOT clause of the
   832  // argument ConditionBuilder. The resulting ConditionBuilder can be used as a
   833  // part of other Condition Expressions or as an argument to the WithCondition()
   834  // method for the Builder struct.
   835  //
   836  // Example:
   837  //
   838  //     // condition represents the condition where the item attribute "Name"
   839  //     // does not begin with "test"
   840  //     condition := expression.Not(expression.Name("Name").BeginsWith("test"))
   841  //
   842  //     // Used in another Condition Expression
   843  //     anotherCondition := expression.Not(condition)
   844  //     // Used to make an Builder
   845  //     builder := expression.NewBuilder().WithCondition(condition)
   846  //
   847  // Expression Equivalent:
   848  //
   849  //     expression.Not(expression.Name("Name").BeginsWith("test"))
   850  //     // Let :prefix be an ExpressionAttributeValue representing the value
   851  //     // "test"
   852  //     "NOT (begins_with (:prefix))"
   853  func Not(conditionBuilder ConditionBuilder) ConditionBuilder {
   854  	return ConditionBuilder{
   855  		conditionList: []ConditionBuilder{conditionBuilder},
   856  		mode:          notCond,
   857  	}
   858  }
   859  
   860  // Not returns a ConditionBuilder representing the logical NOT clause of the
   861  // argument ConditionBuilder. The resulting ConditionBuilder can be used as a
   862  // part of other Condition Expressions or as an argument to the WithCondition()
   863  // method for the Builder struct.
   864  //
   865  // Example:
   866  //
   867  //     // condition represents the condition where the item attribute "Name"
   868  //     // does not begin with "test"
   869  //     condition := expression.Name("Name").BeginsWith("test").Not()
   870  //
   871  //     // Used in another Condition Expression
   872  //     anotherCondition := expression.Not(condition)
   873  //     // Used to make an Builder
   874  //     builder := expression.NewBuilder().WithCondition(condition)
   875  //
   876  // Expression Equivalent:
   877  //
   878  //     expression.Name("Name").BeginsWith("test").Not()
   879  //     // Let :prefix be an ExpressionAttributeValue representing the value
   880  //     // "test"
   881  //     "NOT (begins_with (:prefix))"
   882  func (cb ConditionBuilder) Not() ConditionBuilder {
   883  	return Not(cb)
   884  }
   885  
   886  // Between returns a ConditionBuilder representing the result of the
   887  // BETWEEN function in DynamoDB Condition Expressions. The resulting
   888  // ConditionBuilder can be used as a part of other Condition Expressions or as
   889  // an argument to the WithCondition() method for the Builder struct.
   890  //
   891  // Example:
   892  //
   893  //     // condition represents the condition where the value of the item
   894  //     // attribute "Rating" is between values 5 and 10
   895  //     condition := expression.Between(expression.Name("Rating"), expression.Value(5), expression.Value(10))
   896  //
   897  //     // Used in another Condition Expression
   898  //     anotherCondition := expression.Not(condition)
   899  //     // Used to make an Builder
   900  //     builder := expression.NewBuilder().WithCondition(condition)
   901  //
   902  // Expression Equivalent:
   903  //
   904  //     expression.Between(expression.Name("Rating"), expression.Value(5), expression.Value(10))
   905  //     // Let :five and :ten be ExpressionAttributeValues representing the value
   906  //     // 5 and the value 10
   907  //     "Rating BETWEEN :five AND :ten"
   908  func Between(op, lower, upper OperandBuilder) ConditionBuilder {
   909  	return ConditionBuilder{
   910  		operandList: []OperandBuilder{op, lower, upper},
   911  		mode:        betweenCond,
   912  	}
   913  }
   914  
   915  // Between returns a ConditionBuilder representing the result of the
   916  // BETWEEN function in DynamoDB Condition Expressions. The resulting
   917  // ConditionBuilder can be used as a part of other Condition Expressions or as
   918  // an argument to the WithCondition() method for the Builder struct.
   919  //
   920  // Example:
   921  //
   922  //     // condition represents the condition where the value of the item
   923  //     // attribute "Rating" is between values 5 and 10
   924  //     condition := expression.Name("Rating").Between(expression.Value(5), expression.Value(10))
   925  //
   926  //     // Used in another Condition Expression
   927  //     anotherCondition := expression.Not(condition)
   928  //     // Used to make an Builder
   929  //     builder := expression.NewBuilder().WithCondition(condition)
   930  //
   931  // Expression Equivalent:
   932  //
   933  //     expression.Name("Rating").Between(expression.Value(5), expression.Value(10))
   934  //     // Let :five and :ten be ExpressionAttributeValues representing the value
   935  //     // 5 and the value 10
   936  //     "Rating BETWEEN :five AND :ten"
   937  func (nb NameBuilder) Between(lower, upper OperandBuilder) ConditionBuilder {
   938  	return Between(nb, lower, upper)
   939  }
   940  
   941  // Between returns a ConditionBuilder representing the result of the
   942  // BETWEEN function in DynamoDB Condition Expressions. The resulting
   943  // ConditionBuilder can be used as a part of other Condition Expressions or as
   944  // an argument to the WithCondition() method for the Builder struct.
   945  //
   946  // Example:
   947  //
   948  //     // condition represents the condition where the value 6 is between values
   949  //     // 5 and 10
   950  //     condition := expression.Value(6).Between(expression.Value(5), expression.Value(10))
   951  //
   952  //     // Used in another Condition Expression
   953  //     anotherCondition := expression.Not(condition)
   954  //     // Used to make an Builder
   955  //     builder := expression.NewBuilder().WithCondition(condition)
   956  //
   957  // Expression Equivalent:
   958  //
   959  //     expression.Value(6).Between(expression.Value(5), expression.Value(10))
   960  //     // Let :six, :five and :ten be ExpressionAttributeValues representing the
   961  //     // values 6, 5, and 10 respectively
   962  //     ":six BETWEEN :five AND :ten"
   963  func (vb ValueBuilder) Between(lower, upper OperandBuilder) ConditionBuilder {
   964  	return Between(vb, lower, upper)
   965  }
   966  
   967  // Between returns a ConditionBuilder representing the result of the
   968  // BETWEEN function in DynamoDB Condition Expressions. The resulting
   969  // ConditionBuilder can be used as a part of other Condition Expressions or as
   970  // an argument to the WithCondition() method for the Builder struct.
   971  //
   972  // Example:
   973  //
   974  //     // condition represents the condition where the size of the item
   975  //     // attribute "InviteList" is between values 5 and 10
   976  //     condition := expression.Size(expression.Name("InviteList")).Between(expression.Value(5), expression.Value(10))
   977  //
   978  //     // Used in another Condition Expression
   979  //     anotherCondition := expression.Not(condition)
   980  //     // Used to make an Builder
   981  //     builder := expression.NewBuilder().WithCondition(condition)
   982  //
   983  // Expression Equivalent:
   984  //
   985  //     expression.Size(expression.Name("InviteList")).Between(expression.Value(5), expression.Value(10))
   986  //     // Let :five and :ten be ExpressionAttributeValues representing the value
   987  //     // 5 and the value 10
   988  //     "size (InviteList) BETWEEN :five AND :ten"
   989  func (sb SizeBuilder) Between(lower, upper OperandBuilder) ConditionBuilder {
   990  	return Between(sb, lower, upper)
   991  }
   992  
   993  // In returns a ConditionBuilder representing the result of the IN function
   994  // in DynamoDB Condition Expressions. The resulting ConditionBuilder can be used
   995  // as a part of other Condition Expressions or as an argument to the
   996  // WithCondition() method for the Builder struct.
   997  //
   998  // Example:
   999  //
  1000  //     // condition represents the condition where the value of the item
  1001  //     // attribute "Color" is checked against the list of colors "red",
  1002  //     // "green", and "blue".
  1003  //     condition := expression.In(expression.Name("Color"), expression.Value("red"), expression.Value("green"), expression.Value("blue"))
  1004  //
  1005  //     // Used in another Condition Expression
  1006  //     anotherCondition := expression.Not(condition)
  1007  //     // Used to make an Builder
  1008  //     builder := expression.NewBuilder().WithCondition(condition)
  1009  //
  1010  // Expression Equivalent:
  1011  //
  1012  //     expression.In(expression.Name("Color"), expression.Value("red"), expression.Value("green"), expression.Value("blue"))
  1013  //     // Let :red, :green, :blue be ExpressionAttributeValues representing the
  1014  //     // values "red", "green", and "blue" respectively
  1015  //     "Color IN (:red, :green, :blue)"
  1016  func In(left, right OperandBuilder, other ...OperandBuilder) ConditionBuilder {
  1017  	other = append([]OperandBuilder{left, right}, other...)
  1018  	return ConditionBuilder{
  1019  		operandList: other,
  1020  		mode:        inCond,
  1021  	}
  1022  }
  1023  
  1024  // In returns a ConditionBuilder representing the result of the IN function
  1025  // in DynamoDB Condition Expressions. The resulting ConditionBuilder can be used
  1026  // as a part of other Condition Expressions or as an argument to the
  1027  // WithCondition() method for the Builder struct.
  1028  //
  1029  // Example:
  1030  //
  1031  //     // condition represents the condition where the value of the item
  1032  //     // attribute "Color" is checked against the list of colors "red",
  1033  //     // "green", and "blue".
  1034  //     condition := expression.Name("Color").In(expression.Value("red"), expression.Value("green"), expression.Value("blue"))
  1035  //
  1036  //     // Used in another Condition Expression
  1037  //     anotherCondition := expression.Not(condition)
  1038  //     // Used to make an Builder
  1039  //     builder := expression.NewBuilder().WithCondition(condition)
  1040  //
  1041  // Expression Equivalent:
  1042  //
  1043  //     expression.Name("Color").In(expression.Value("red"), expression.Value("green"), expression.Value("blue"))
  1044  //     // Let :red, :green, :blue be ExpressionAttributeValues representing the
  1045  //     // values "red", "green", and "blue" respectively
  1046  //     "Color IN (:red, :green, :blue)"
  1047  func (nb NameBuilder) In(right OperandBuilder, other ...OperandBuilder) ConditionBuilder {
  1048  	return In(nb, right, other...)
  1049  }
  1050  
  1051  // In returns a ConditionBuilder representing the result of the IN function
  1052  // TODO change this one
  1053  // in DynamoDB Condition Expressions. The resulting ConditionBuilder can be used
  1054  // as a part of other Condition Expressions or as an argument to the
  1055  // WithCondition() method for the Builder struct.
  1056  //
  1057  // Example:
  1058  //
  1059  //     // condition represents the condition where the value "yellow" is checked
  1060  //     // against the list of colors "red", "green", and "blue".
  1061  //     condition := expression.Value("yellow").In(expression.Value("red"), expression.Value("green"), expression.Value("blue"))
  1062  //
  1063  //     // Used in another Condition Expression
  1064  //     anotherCondition := expression.Not(condition)
  1065  //     // Used to make an Builder
  1066  //     builder := expression.NewBuilder().WithCondition(condition)
  1067  //
  1068  // Expression Equivalent:
  1069  //
  1070  //     expression.Value("yellow").In(expression.Value("red"), expression.Value("green"), expression.Value("blue"))
  1071  //     // Let :yellow, :red, :green, :blue be ExpressionAttributeValues
  1072  //     // representing the values "yellow", "red", "green", and "blue"
  1073  //     // respectively
  1074  //     ":yellow IN (:red, :green, :blue)"
  1075  func (vb ValueBuilder) In(right OperandBuilder, other ...OperandBuilder) ConditionBuilder {
  1076  	return In(vb, right, other...)
  1077  }
  1078  
  1079  // In returns a ConditionBuilder representing the result of the IN function
  1080  // in DynamoDB Condition Expressions. The resulting ConditionBuilder can be used
  1081  // as a part of other Condition Expressions or as an argument to the
  1082  // WithCondition() method for the Builder struct.
  1083  //
  1084  // Example:
  1085  //
  1086  //     // condition represents the condition where the size of the item
  1087  //     // attribute "Donuts" is checked against the list of numbers 12, 24, and
  1088  //     // 36.
  1089  //     condition := expression.Size(expression.Name("Donuts")).In(expression.Value(12), expression.Value(24), expression.Value(36))
  1090  //
  1091  //     // Used in another Condition Expression
  1092  //     anotherCondition := expression.Not(condition)
  1093  //     // Used to make an Builder
  1094  //     builder := expression.NewBuilder().WithCondition(condition)
  1095  //
  1096  // Expression Equivalent:
  1097  //
  1098  //     expression.Size(expression.Name("Donuts")).In(expression.Value(12), expression.Value(24), expression.Value(36))
  1099  //     // Let :dozen, :twoDozen, :threeDozen be ExpressionAttributeValues
  1100  //     // representing the values 12, 24, and 36 respectively
  1101  //     "size (Donuts) IN (12, 24, 36)"
  1102  func (sb SizeBuilder) In(right OperandBuilder, other ...OperandBuilder) ConditionBuilder {
  1103  	return In(sb, right, other...)
  1104  }
  1105  
  1106  // AttributeExists returns a ConditionBuilder representing the result of the
  1107  // attribute_exists function in DynamoDB Condition Expressions. The resulting
  1108  // ConditionBuilder can be used as a part of other Condition Expressions or as
  1109  // an argument to the WithCondition() method for the Builder struct.
  1110  //
  1111  // Example:
  1112  //
  1113  //     // condition represents the boolean condition of whether the item
  1114  //     // attribute "Age" exists or not
  1115  //     condition := expression.AttributeExists(expression.Name("Age"))
  1116  //
  1117  //     // Used in another Condition Expression
  1118  //     anotherCondition := expression.Not(condition)
  1119  //     // Used to make an Builder
  1120  //     builder := expression.NewBuilder().WithCondition(condition)
  1121  //
  1122  // Expression Equivalent:
  1123  //
  1124  //     expression.AttributeExists(expression.Name("Age"))
  1125  //     "attribute_exists (Age))"
  1126  func AttributeExists(nameBuilder NameBuilder) ConditionBuilder {
  1127  	return ConditionBuilder{
  1128  		operandList: []OperandBuilder{nameBuilder},
  1129  		mode:        attrExistsCond,
  1130  	}
  1131  }
  1132  
  1133  // AttributeExists returns a ConditionBuilder representing the result of the
  1134  // attribute_exists function in DynamoDB Condition Expressions. The resulting
  1135  // ConditionBuilder can be used as a part of other Condition Expressions or as
  1136  // an argument to the WithCondition() method for the Builder struct.
  1137  //
  1138  // Example:
  1139  //
  1140  //     // condition represents the boolean condition of whether the item
  1141  //     // attribute "Age" exists or not
  1142  //     condition := expression.Name("Age").AttributeExists()
  1143  //
  1144  //     // Used in another Condition Expression
  1145  //     anotherCondition := expression.Not(condition)
  1146  //     // Used to make an Builder
  1147  //     builder := expression.NewBuilder().WithCondition(condition)
  1148  //
  1149  // Expression Equivalent:
  1150  //
  1151  //     expression.Name("Age").AttributeExists()
  1152  //     "attribute_exists (Age))"
  1153  func (nb NameBuilder) AttributeExists() ConditionBuilder {
  1154  	return AttributeExists(nb)
  1155  }
  1156  
  1157  // AttributeNotExists returns a ConditionBuilder representing the result of
  1158  // the attribute_not_exists function in DynamoDB Condition Expressions. The
  1159  // resulting ConditionBuilder can be used as a part of other Condition
  1160  // Expressions or as an argument to the WithCondition() method for the Builder
  1161  // struct.
  1162  //
  1163  // Example:
  1164  //
  1165  //     // condition represents the boolean condition of whether the item
  1166  //     // attribute "Age" exists or not
  1167  //     condition := expression.AttributeNotExists(expression.Name("Age"))
  1168  //
  1169  //     // Used in another Condition Expression
  1170  //     anotherCondition := expression.Not(condition)
  1171  //     // Used to make an Builder
  1172  //     builder := expression.NewBuilder().WithCondition(condition)
  1173  //
  1174  // Expression Equivalent:
  1175  //
  1176  //     expression.AttributeNotExists(expression.Name("Age"))
  1177  //     "attribute_not_exists (Age))"
  1178  func AttributeNotExists(nameBuilder NameBuilder) ConditionBuilder {
  1179  	return ConditionBuilder{
  1180  		operandList: []OperandBuilder{nameBuilder},
  1181  		mode:        attrNotExistsCond,
  1182  	}
  1183  }
  1184  
  1185  // AttributeNotExists returns a ConditionBuilder representing the result of
  1186  // the attribute_not_exists function in DynamoDB Condition Expressions. The
  1187  // resulting ConditionBuilder can be used as a part of other Condition
  1188  // Expressions or as an argument to the WithCondition() method for the Builder
  1189  // struct.
  1190  //
  1191  // Example:
  1192  //
  1193  //     // condition represents the boolean condition of whether the item
  1194  //     // attribute "Age" exists or not
  1195  //     condition := expression.Name("Age").AttributeNotExists()
  1196  //
  1197  //     // Used in another Condition Expression
  1198  //     anotherCondition := expression.Not(condition)
  1199  //     // Used to make an Builder
  1200  //     builder := expression.NewBuilder().WithCondition(condition)
  1201  //
  1202  // Expression Equivalent:
  1203  //
  1204  //     expression.Name("Age").AttributeNotExists()
  1205  //     "attribute_not_exists (Age))"
  1206  func (nb NameBuilder) AttributeNotExists() ConditionBuilder {
  1207  	return AttributeNotExists(nb)
  1208  }
  1209  
  1210  // AttributeType returns a ConditionBuilder representing the result of the
  1211  // attribute_type function in DynamoDB Condition Expressions. The DynamoDB types
  1212  // are represented by the type DynamoDBAttributeType. The resulting
  1213  // ConditionBuilder can be used as a part of other Condition Expressions or as
  1214  // an argument to the WithCondition() method for the Builder struct.
  1215  //
  1216  // Example:
  1217  //
  1218  //     // condition represents the boolean condition of whether the item
  1219  //     // attribute "Age" has the DynamoDB type Number or not
  1220  //     condition := expression.AttributeType(expression.Name("Age"), expression.Number)
  1221  //
  1222  //     // Used in another Condition Expression
  1223  //     anotherCondition := expression.Not(condition)
  1224  //     // Used to make an Builder
  1225  //     builder := expression.NewBuilder().WithCondition(condition)
  1226  //
  1227  // Expression Equivalent:
  1228  //
  1229  //     expression.AttributeType(expression.Name("Age"), expression.Number)
  1230  //     // Let :type be an ExpressionAttributeValue representing the value "N"
  1231  //     "attribute_type (Age, :type)"
  1232  func AttributeType(nameBuilder NameBuilder, attributeType DynamoDBAttributeType) ConditionBuilder {
  1233  	v := ValueBuilder{
  1234  		value: string(attributeType),
  1235  	}
  1236  	return ConditionBuilder{
  1237  		operandList: []OperandBuilder{nameBuilder, v},
  1238  		mode:        attrTypeCond,
  1239  	}
  1240  }
  1241  
  1242  // AttributeType returns a ConditionBuilder representing the result of the
  1243  // attribute_type function in DynamoDB Condition Expressions. The DynamoDB types
  1244  // are represented by the type DynamoDBAttributeType. The resulting
  1245  // ConditionBuilder can be used as a part of other Condition Expressions or as
  1246  // an argument to the WithCondition() method for the Builder struct.
  1247  //
  1248  // Example:
  1249  //
  1250  //     // condition represents the boolean condition of whether the item
  1251  //     // attribute "Age" has the DynamoDB type Number or not
  1252  //     condition := expression.Name("Age").AttributeType(expression.Number)
  1253  //
  1254  //     // Used in another Condition Expression
  1255  //     anotherCondition := expression.Not(condition)
  1256  //     // Used to make an Builder
  1257  //     builder := expression.NewBuilder().WithCondition(condition)
  1258  //
  1259  // Expression Equivalent:
  1260  //
  1261  //     expression.Name("Age").AttributeType(expression.Number)
  1262  //     // Let :type be an ExpressionAttributeValue representing the value "N"
  1263  //     "attribute_type (Age, :type)"
  1264  func (nb NameBuilder) AttributeType(attributeType DynamoDBAttributeType) ConditionBuilder {
  1265  	return AttributeType(nb, attributeType)
  1266  }
  1267  
  1268  // BeginsWith returns a ConditionBuilder representing the result of the
  1269  // begins_with function in DynamoDB Condition Expressions. The resulting
  1270  // ConditionBuilder can be used as a part of other Condition Expressions or as
  1271  // an argument to the WithCondition() method for the Builder struct.
  1272  //
  1273  // Example:
  1274  //
  1275  //     // condition represents the boolean condition of whether the item
  1276  //     // attribute "CodeName" starts with the substring "Ben"
  1277  //     condition := expression.BeginsWith(expression.Name("CodeName"), "Ben")
  1278  //
  1279  //     // Used in another Condition Expression
  1280  //     anotherCondition := expression.Not(condition)
  1281  //     // Used to make an Builder
  1282  //     builder := expression.NewBuilder().WithCondition(condition)
  1283  //
  1284  // Expression Equivalent:
  1285  //
  1286  //     expression.BeginsWith(expression.Name("CodeName"), "Ben")
  1287  //     // Let :ben be an ExpressionAttributeValue representing the value "Ben"
  1288  //     "begins_with (CodeName, :ben)"
  1289  func BeginsWith(nameBuilder NameBuilder, prefix string) ConditionBuilder {
  1290  	v := ValueBuilder{
  1291  		value: prefix,
  1292  	}
  1293  	return ConditionBuilder{
  1294  		operandList: []OperandBuilder{nameBuilder, v},
  1295  		mode:        beginsWithCond,
  1296  	}
  1297  }
  1298  
  1299  // BeginsWith returns a ConditionBuilder representing the result of the
  1300  // begins_with function in DynamoDB Condition Expressions. The resulting
  1301  // ConditionBuilder can be used as a part of other Condition Expressions or as
  1302  // an argument to the WithCondition() method for the Builder struct.
  1303  //
  1304  // Example:
  1305  //
  1306  //     // condition represents the boolean condition of whether the item
  1307  //     // attribute "CodeName" starts with the substring "Ben"
  1308  //     condition := expression.Name("CodeName").BeginsWith("Ben")
  1309  //
  1310  //     // Used in another Condition Expression
  1311  //     anotherCondition := expression.Not(condition)
  1312  //     // Used to make an Builder
  1313  //     builder := expression.NewBuilder().WithCondition(condition)
  1314  //
  1315  // Expression Equivalent:
  1316  //
  1317  //     expression.Name("CodeName").BeginsWith("Ben")
  1318  //     // Let :ben be an ExpressionAttributeValue representing the value "Ben"
  1319  //     "begins_with (CodeName, :ben)"
  1320  func (nb NameBuilder) BeginsWith(prefix string) ConditionBuilder {
  1321  	return BeginsWith(nb, prefix)
  1322  }
  1323  
  1324  // Contains returns a ConditionBuilder representing the result of the
  1325  // contains function in DynamoDB Condition Expressions. The resulting
  1326  // ConditionBuilder can be used as a part of other Condition Expressions or as
  1327  // an argument to the WithCondition() method for the Builder struct.
  1328  //
  1329  // Example:
  1330  //
  1331  //     // condition represents the boolean condition of whether the item
  1332  //     // attribute "InviteList" has the value "Ben"
  1333  //     condition := expression.Contains(expression.Name("InviteList"), "Ben")
  1334  //
  1335  //     // Used in another Condition Expression
  1336  //     anotherCondition := expression.Not(condition)
  1337  //     // Used to make an Builder
  1338  //     builder := expression.NewBuilder().WithCondition(condition)
  1339  //
  1340  // Expression Equivalent:
  1341  //
  1342  //     expression.Contains(expression.Name("InviteList"), "Ben")
  1343  //     // Let :ben be an ExpressionAttributeValue representing the value "Ben"
  1344  //     "contains (InviteList, :ben)"
  1345  func Contains(nameBuilder NameBuilder, substr string) ConditionBuilder {
  1346  	v := ValueBuilder{
  1347  		value: substr,
  1348  	}
  1349  	return ConditionBuilder{
  1350  		operandList: []OperandBuilder{nameBuilder, v},
  1351  		mode:        containsCond,
  1352  	}
  1353  }
  1354  
  1355  // Contains returns a ConditionBuilder representing the result of the
  1356  // contains function in DynamoDB Condition Expressions. The resulting
  1357  // ConditionBuilder can be used as a part of other Condition Expressions or as
  1358  // an argument to the WithCondition() method for the Builder struct.
  1359  //
  1360  // Example:
  1361  //
  1362  //     // condition represents the boolean condition of whether the item
  1363  //     // attribute "InviteList" has the value "Ben"
  1364  //     condition := expression.Name("InviteList").Contains("Ben")
  1365  //
  1366  //     // Used in another Condition Expression
  1367  //     anotherCondition := expression.Not(condition)
  1368  //     // Used to make an Builder
  1369  //     builder := expression.NewBuilder().WithCondition(condition)
  1370  //
  1371  // Expression Equivalent:
  1372  //
  1373  //     expression.Name("InviteList").Contains("Ben")
  1374  //     // Let :ben be an ExpressionAttributeValue representing the value "Ben"
  1375  //     "contains (InviteList, :ben)"
  1376  func (nb NameBuilder) Contains(substr string) ConditionBuilder {
  1377  	return Contains(nb, substr)
  1378  }
  1379  
  1380  // buildTree builds a tree structure of exprNodes based on the tree
  1381  // structure of the input ConditionBuilder's child ConditionBuilders and
  1382  // OperandBuilders. buildTree() satisfies the treeBuilder interface so
  1383  // ConditionBuilder can be a part of Builder and Expression struct.
  1384  func (cb ConditionBuilder) buildTree() (exprNode, error) {
  1385  	childNodes, err := cb.buildChildNodes()
  1386  	if err != nil {
  1387  		return exprNode{}, err
  1388  	}
  1389  	ret := exprNode{
  1390  		children: childNodes,
  1391  	}
  1392  
  1393  	switch cb.mode {
  1394  	case equalCond, notEqualCond, lessThanCond, lessThanEqualCond, greaterThanCond, greaterThanEqualCond:
  1395  		return compareBuildCondition(cb.mode, ret)
  1396  	case andCond, orCond:
  1397  		return compoundBuildCondition(cb, ret)
  1398  	case notCond:
  1399  		return notBuildCondition(ret)
  1400  	case betweenCond:
  1401  		return betweenBuildCondition(ret)
  1402  	case inCond:
  1403  		return inBuildCondition(cb, ret)
  1404  	case attrExistsCond:
  1405  		return attrExistsBuildCondition(ret)
  1406  	case attrNotExistsCond:
  1407  		return attrNotExistsBuildCondition(ret)
  1408  	case attrTypeCond:
  1409  		return attrTypeBuildCondition(ret)
  1410  	case beginsWithCond:
  1411  		return beginsWithBuildCondition(ret)
  1412  	case containsCond:
  1413  		return containsBuildCondition(ret)
  1414  	case unsetCond:
  1415  		return exprNode{}, newUnsetParameterError("buildTree", "ConditionBuilder")
  1416  	default:
  1417  		return exprNode{}, fmt.Errorf("build condition error: unsupported mode: %v", cb.mode)
  1418  	}
  1419  }
  1420  
  1421  // compareBuildCondition is the function to make exprNodes from Compare
  1422  // ConditionBuilders. compareBuildCondition is only called by the
  1423  // buildTree method. This function assumes that the argument ConditionBuilder
  1424  // has the right format.
  1425  func compareBuildCondition(conditionMode conditionMode, node exprNode) (exprNode, error) {
  1426  	// Create a string with special characters that can be substituted later: $c
  1427  	switch conditionMode {
  1428  	case equalCond:
  1429  		node.fmtExpr = "$c = $c"
  1430  	case notEqualCond:
  1431  		node.fmtExpr = "$c <> $c"
  1432  	case lessThanCond:
  1433  		node.fmtExpr = "$c < $c"
  1434  	case lessThanEqualCond:
  1435  		node.fmtExpr = "$c <= $c"
  1436  	case greaterThanCond:
  1437  		node.fmtExpr = "$c > $c"
  1438  	case greaterThanEqualCond:
  1439  		node.fmtExpr = "$c >= $c"
  1440  	default:
  1441  		return exprNode{}, fmt.Errorf("build compare condition error: unsupported mode: %v", conditionMode)
  1442  	}
  1443  
  1444  	return node, nil
  1445  }
  1446  
  1447  // compoundBuildCondition is the function to make exprNodes from And/Or
  1448  // ConditionBuilders. compoundBuildCondition is only called by the
  1449  // buildTree method. This function assumes that the argument ConditionBuilder
  1450  // has the right format.
  1451  func compoundBuildCondition(conditionBuilder ConditionBuilder, node exprNode) (exprNode, error) {
  1452  	// create a string with escaped characters to substitute them with proper
  1453  	// aliases during runtime
  1454  	var mode string
  1455  	switch conditionBuilder.mode {
  1456  	case andCond:
  1457  		mode = " AND "
  1458  	case orCond:
  1459  		mode = " OR "
  1460  	default:
  1461  		return exprNode{}, fmt.Errorf("build compound condition error: unsupported mode: %v", conditionBuilder.mode)
  1462  	}
  1463  	node.fmtExpr = "($c)" + strings.Repeat(mode+"($c)", len(conditionBuilder.conditionList)-1)
  1464  
  1465  	return node, nil
  1466  }
  1467  
  1468  // notBuildCondition is the function to make exprNodes from Not
  1469  // ConditionBuilders. notBuildCondition is only called by the
  1470  // buildTree method. This function assumes that the argument ConditionBuilder
  1471  // has the right format.
  1472  func notBuildCondition(node exprNode) (exprNode, error) {
  1473  	// create a string with escaped characters to substitute them with proper
  1474  	// aliases during runtime
  1475  	node.fmtExpr = "NOT ($c)"
  1476  
  1477  	return node, nil
  1478  }
  1479  
  1480  // betweenBuildCondition is the function to make exprNodes from Between
  1481  // ConditionBuilders. BuildCondition is only called by the
  1482  // buildTree method. This function assumes that the argument ConditionBuilder
  1483  // has the right format.
  1484  func betweenBuildCondition(node exprNode) (exprNode, error) {
  1485  	// Create a string with special characters that can be substituted later: $c
  1486  	node.fmtExpr = "$c BETWEEN $c AND $c"
  1487  
  1488  	return node, nil
  1489  }
  1490  
  1491  // inBuildCondition is the function to make exprNodes from In
  1492  // ConditionBuilders. inBuildCondition is only called by the
  1493  // buildTree method. This function assumes that the argument ConditionBuilder
  1494  // has the right format.
  1495  func inBuildCondition(conditionBuilder ConditionBuilder, node exprNode) (exprNode, error) {
  1496  	// Create a string with special characters that can be substituted later: $c
  1497  	node.fmtExpr = "$c IN ($c" + strings.Repeat(", $c", len(conditionBuilder.operandList)-2) + ")"
  1498  
  1499  	return node, nil
  1500  }
  1501  
  1502  // attrExistsBuildCondition is the function to make exprNodes from
  1503  // AttrExistsCond ConditionBuilders. attrExistsBuildCondition is only
  1504  // called by the buildTree method. This function assumes that the argument
  1505  // ConditionBuilder has the right format.
  1506  func attrExistsBuildCondition(node exprNode) (exprNode, error) {
  1507  	// Create a string with special characters that can be substituted later: $c
  1508  	node.fmtExpr = "attribute_exists ($c)"
  1509  
  1510  	return node, nil
  1511  }
  1512  
  1513  // attrNotExistsBuildCondition is the function to make exprNodes from
  1514  // AttrNotExistsCond ConditionBuilders. attrNotExistsBuildCondition is only
  1515  // called by the buildTree method. This function assumes that the argument
  1516  // ConditionBuilder has the right format.
  1517  func attrNotExistsBuildCondition(node exprNode) (exprNode, error) {
  1518  	// Create a string with special characters that can be substituted later: $c
  1519  	node.fmtExpr = "attribute_not_exists ($c)"
  1520  
  1521  	return node, nil
  1522  }
  1523  
  1524  // attrTypeBuildCondition is the function to make exprNodes from AttrTypeCond
  1525  // ConditionBuilders. attrTypeBuildCondition is only called by the
  1526  // buildTree method. This function assumes that the argument
  1527  // ConditionBuilder has the right format.
  1528  func attrTypeBuildCondition(node exprNode) (exprNode, error) {
  1529  	// Create a string with special characters that can be substituted later: $c
  1530  	node.fmtExpr = "attribute_type ($c, $c)"
  1531  
  1532  	return node, nil
  1533  }
  1534  
  1535  // beginsWithBuildCondition is the function to make exprNodes from
  1536  // BeginsWithCond ConditionBuilders. beginsWithBuildCondition is only
  1537  // called by the buildTree method. This function assumes that the argument
  1538  // ConditionBuilder has the right format.
  1539  func beginsWithBuildCondition(node exprNode) (exprNode, error) {
  1540  	// Create a string with special characters that can be substituted later: $c
  1541  	node.fmtExpr = "begins_with ($c, $c)"
  1542  
  1543  	return node, nil
  1544  }
  1545  
  1546  // containsBuildCondition is the function to make exprNodes from
  1547  // ContainsCond ConditionBuilders. containsBuildCondition is only
  1548  // called by the buildTree method. This function assumes that the argument
  1549  // ConditionBuilder has the right format.
  1550  func containsBuildCondition(node exprNode) (exprNode, error) {
  1551  	// Create a string with special characters that can be substituted later: $c
  1552  	node.fmtExpr = "contains ($c, $c)"
  1553  
  1554  	return node, nil
  1555  }
  1556  
  1557  // buildChildNodes creates the list of the child exprNodes. This avoids
  1558  // duplication of code amongst the various buildTree functions.
  1559  func (cb ConditionBuilder) buildChildNodes() ([]exprNode, error) {
  1560  	childNodes := make([]exprNode, 0, len(cb.conditionList)+len(cb.operandList))
  1561  	for _, condition := range cb.conditionList {
  1562  		node, err := condition.buildTree()
  1563  		if err != nil {
  1564  			return []exprNode{}, err
  1565  		}
  1566  		childNodes = append(childNodes, node)
  1567  	}
  1568  	for _, ope := range cb.operandList {
  1569  		operand, err := ope.BuildOperand()
  1570  		if err != nil {
  1571  			return []exprNode{}, err
  1572  		}
  1573  		childNodes = append(childNodes, operand.exprNode)
  1574  	}
  1575  
  1576  	return childNodes, nil
  1577  }