-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
condition.go
1577 lines (1499 loc) · 59.9 KB
/
condition.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package expression
import (
"fmt"
"strings"
)
// conditionMode specifies the types of the struct conditionBuilder,
// representing the different types of Conditions (i.e. And, Or, Between, ...)
type conditionMode int
const (
// unsetCond catches errors for unset ConditionBuilder structs
unsetCond conditionMode = iota
// equalCond represents the Equals Condition
equalCond
// notEqualCond represents the Not Equals Condition
notEqualCond
// lessThanCond represents the LessThan Condition
lessThanCond
// lessThanEqualCond represents the LessThanOrEqual Condition
lessThanEqualCond
// greaterThanCond represents the GreaterThan Condition
greaterThanCond
// greaterThanEqualCond represents the GreaterThanEqual Condition
greaterThanEqualCond
// andCond represents the Logical And Condition
andCond
// orCond represents the Logical Or Condition
orCond
// notCond represents the Logical Not Condition
notCond
// betweenCond represents the Between Condition
betweenCond
// inCond represents the In Condition
inCond
// attrExistsCond represents the Attribute Exists Condition
attrExistsCond
// attrNotExistsCond represents the Attribute Not Exists Condition
attrNotExistsCond
// attrTypeCond represents the Attribute Type Condition
attrTypeCond
// beginsWithCond represents the Begins With Condition
beginsWithCond
// containsCond represents the Contains Condition
containsCond
)
// DynamoDBAttributeType specifies the type of an DynamoDB item attribute. This
// enum is used in the AttributeType() function in order to be explicit about
// the DynamoDB type that is being checked and ensure compile time checks.
// More Informatin at http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions
type DynamoDBAttributeType string
const (
// String represents the DynamoDB String type
String DynamoDBAttributeType = "S"
// StringSet represents the DynamoDB String Set type
StringSet = "SS"
// Number represents the DynamoDB Number type
Number = "N"
// NumberSet represents the DynamoDB Number Set type
NumberSet = "NS"
// Binary represents the DynamoDB Binary type
Binary = "B"
// BinarySet represents the DynamoDB Binary Set type
BinarySet = "BS"
// Boolean represents the DynamoDB Boolean type
Boolean = "BOOL"
// Null represents the DynamoDB Null type
Null = "NULL"
// List represents the DynamoDB List type
List = "L"
// Map represents the DynamoDB Map type
Map = "M"
)
// ConditionBuilder represents Condition Expressions and Filter Expressions
// in DynamoDB. ConditionBuilders are one of the building blocks of the Builder
// struct. Since Filter Expressions support all the same functions and formats
// as Condition Expressions, ConditionBuilders represents both types of
// Expressions.
// More Information at: http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.ConditionExpressions.html
// More Information on Filter Expressions: http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Query.html#Query.FilterExpression
type ConditionBuilder struct {
operandList []OperandBuilder
conditionList []ConditionBuilder
mode conditionMode
}
// Equal returns a ConditionBuilder representing the equality clause of the two
// argument OperandBuilders. The resulting ConditionBuilder can be used as a
// part of other Condition Expressions or as an argument to the WithCondition()
// method for the Builder struct.
//
// Example:
//
// // condition represents the equal clause of the item attribute "foo" and
// // the value 5
// condition := expression.Equal(expression.Name("foo"), expression.Value(5))
//
// // Used in another Condition Expression
// anotherCondition := expression.Not(condition)
// // Used to make an Builder
// builder := expression.NewBuilder().WithCondition(condition)
//
// Expression Equivalent:
//
// expression.Equal(expression.Name("foo"), expression.Value(5))
// // Let :five be an ExpressionAttributeValue representing the value 5
// "foo = :five"
func Equal(left, right OperandBuilder) ConditionBuilder {
return ConditionBuilder{
operandList: []OperandBuilder{left, right},
mode: equalCond,
}
}
// Equal returns a ConditionBuilder representing the equality clause of the two
// argument OperandBuilders. The resulting ConditionBuilder can be used as a
// part of other Condition Expressions or as an argument to the WithCondition()
// method for the Builder struct.
//
// Example:
//
// // condition represents the equal clause of the item attribute "foo" and
// // the value 5
// condition := expression.Name("foo").Equal(expression.Value(5))
//
// // Used in another Condition Expression
// anotherCondition := expression.Not(condition)
// // Used to make an Builder
// builder := expression.NewBuilder().WithCondition(condition)
//
// Expression Equivalent:
//
// expression.Name("foo").Equal(expression.Value(5))
// // Let :five be an ExpressionAttributeValue representing the value 5
// "foo = :five"
func (nb NameBuilder) Equal(right OperandBuilder) ConditionBuilder {
return Equal(nb, right)
}
// Equal returns a ConditionBuilder representing the equality clause of the two
// argument OperandBuilders. The resulting ConditionBuilder can be used as a
// part of other Condition Expressions or as an argument to the WithCondition()
// method for the Builder struct.
//
// Example:
//
// // condition represents the equal clause of the item attribute "foo" and
// // the value 5
// condition := expression.Value(5).Equal(expression.Name("foo"))
//
// // Used in another Condition Expression
// anotherCondition := expression.Not(condition)
// // Used to make an Builder
// builder := expression.NewBuilder().WithCondition(condition)
//
// Expression Equivalent:
//
// expression.Value(5).Equal(expression.Name("foo"))
// // Let :five be an ExpressionAttributeValue representing the value 5
// ":five = foo"
func (vb ValueBuilder) Equal(right OperandBuilder) ConditionBuilder {
return Equal(vb, right)
}
// Equal returns a ConditionBuilder representing the equality clause of the two
// argument OperandBuilders. The resulting ConditionBuilder can be used as a
// part of other Condition Expressions or as an argument to the WithCondition()
// method for the Builder struct.
//
// Example:
//
// // condition represents the equal clause of the size of the item
// // attribute "foo" and the value 5
// condition := expression.Size(expression.Name("foo")).Equal(expression.Value(5))
//
// // Used in another Condition Expression
// anotherCondition := expression.Not(condition)
// // Used to make an Builder
// builder := expression.NewBuilder().WithCondition(condition)
//
// Expression Equivalent:
//
// expression.Size(expression.Name("foo")).Equal(expression.Value(5))
// // Let :five be an ExpressionAttributeValue representing the value 5
// "size (foo) = :five"
func (sb SizeBuilder) Equal(right OperandBuilder) ConditionBuilder {
return Equal(sb, right)
}
// NotEqual returns a ConditionBuilder representing the not equal clause of the
// two argument OperandBuilders. The resulting ConditionBuilder can be used as a
// part of other Condition Expressions or as an argument to the WithCondition()
// method for the Builder struct.
//
// Example:
//
// // condition represents the not equal clause of the item attribute "foo"
// // and the value 5
// condition := expression.NotEqual(expression.Name("foo"), expression.Value(5))
//
// // Used in another Condition Expression
// anotherCondition := expression.Not(condition)
// // Used to make an Builder
// builder := expression.NewBuilder().WithCondition(condition)
//
// Expression Equivalent:
//
// expression.NotEqual(expression.Name("foo"), expression.Value(5))
// // Let :five be an ExpressionAttributeValue representing the value 5
// "foo <> :five"
func NotEqual(left, right OperandBuilder) ConditionBuilder {
return ConditionBuilder{
operandList: []OperandBuilder{left, right},
mode: notEqualCond,
}
}
// NotEqual returns a ConditionBuilder representing the not equal clause of the
// two argument OperandBuilders. The resulting ConditionBuilder can be used as a
// part of other Condition Expressions or as an argument to the WithCondition()
// method for the Builder struct.
//
// Example:
//
// // condition represents the not equal clause of the item attribute "foo"
// // and the value 5
// condition := expression.Name("foo").NotEqual(expression.Value(5))
//
// // Used in another Condition Expression
// anotherCondition := expression.Not(condition)
// // Used to make an Builder
// builder := expression.NewBuilder().WithCondition(condition)
//
// Expression Equivalent:
//
// expression.Name("foo").NotEqual(expression.Value(5))
// // Let :five be an ExpressionAttributeValue representing the value 5
// "foo <> :five"
func (nb NameBuilder) NotEqual(right OperandBuilder) ConditionBuilder {
return NotEqual(nb, right)
}
// NotEqual returns a ConditionBuilder representing the not equal clause of the
// two argument OperandBuilders. The resulting ConditionBuilder can be used as a
// part of other Condition Expressions or as an argument to the WithCondition()
// method for the Builder struct.
//
// Example:
//
// // condition represents the not equal clause of the item attribute "foo"
// // and the value 5
// condition := expression.Value(5).NotEqual(expression.Name("foo"))
//
// // Used in another Condition Expression
// anotherCondition := expression.Not(condition)
// // Used to make an Builder
// builder := expression.NewBuilder().WithCondition(condition)
//
// Expression Equivalent:
//
// expression.Value(5).NotEqual(expression.Name("foo"))
// // Let :five be an ExpressionAttributeValue representing the value 5
// ":five <> foo"
func (vb ValueBuilder) NotEqual(right OperandBuilder) ConditionBuilder {
return NotEqual(vb, right)
}
// NotEqual returns a ConditionBuilder representing the not equal clause of the
// two argument OperandBuilders. The resulting ConditionBuilder can be used as a
// part of other Condition Expressions or as an argument to the WithCondition()
// method for the Builder struct.
//
// Example:
//
// // condition represents the not equal clause of the size of the item
// // attribute "foo" and the value 5
// condition := expression.Size(expression.Name("foo")).NotEqual(expression.Value(5))
//
// // Used in another Condition Expression
// anotherCondition := expression.Not(condition)
// // Used to make an Builder
// builder := expression.NewBuilder().WithCondition(condition)
//
// Expression Equivalent:
//
// expression.Size(expression.Name("foo")).NotEqual(expression.Value(5))
// // Let :five be an ExpressionAttributeValue representing the value 5
// "size (foo) <> :five"
func (sb SizeBuilder) NotEqual(right OperandBuilder) ConditionBuilder {
return NotEqual(sb, right)
}
// LessThan returns a ConditionBuilder representing the less than clause of the
// two argument OperandBuilders. The resulting ConditionBuilder can be used as a
// part of other Condition Expressions or as an argument to the WithCondition()
// method for the Builder struct.
//
// Example:
//
// // condition represents the less than clause of the item attribute "foo"
// // and the value 5
// condition := expression.LessThan(expression.Name("foo"), expression.Value(5))
//
// // Used in another Condition Expression
// anotherCondition := expression.Not(condition)
// // Used to make an Builder
// builder := expression.NewBuilder().WithCondition(condition)
//
// Expression Equivalent:
//
// expression.LessThan(expression.Name("foo"), expression.Value(5))
// // Let :five be an ExpressionAttributeValue representing the value 5
// "foo < :five"
func LessThan(left, right OperandBuilder) ConditionBuilder {
return ConditionBuilder{
operandList: []OperandBuilder{left, right},
mode: lessThanCond,
}
}
// LessThan returns a ConditionBuilder representing the less than clause of the
// two argument OperandBuilders. The resulting ConditionBuilder can be used as a
// part of other Condition Expressions or as an argument to the WithCondition()
// method for the Builder struct.
//
// Example:
//
// // condition represents the less than clause of the item attribute "foo"
// // and the value 5
// condition := expression.Name("foo").LessThan(expression.Value(5))
//
// // Used in another Condition Expression
// anotherCondition := expression.Not(condition)
// // Used to make an Builder
// builder := expression.NewBuilder().WithCondition(condition)
//
// Expression Equivalent:
//
// expression.Name("foo").LessThan(expression.Value(5))
// // Let :five be an ExpressionAttributeValue representing the value 5
// "foo < :five"
func (nb NameBuilder) LessThan(right OperandBuilder) ConditionBuilder {
return LessThan(nb, right)
}
// LessThan returns a ConditionBuilder representing the less than clause of the
// two argument OperandBuilders. The resulting ConditionBuilder can be used as a
// part of other Condition Expressions or as an argument to the WithCondition()
// method for the Builder struct.
//
// Example:
//
// // condition represents the less than clause of the item attribute "foo"
// // and the value 5
// condition := expression.Value(5).LessThan(expression.Name("foo"))
//
// // Used in another Condition Expression
// anotherCondition := expression.Not(condition)
// // Used to make an Builder
// builder := expression.NewBuilder().WithCondition(condition)
//
// Expression Equivalent:
//
// expression.Value(5).LessThan(expression.Name("foo"))
// // Let :five be an ExpressionAttributeValue representing the value 5
// ":five < foo"
func (vb ValueBuilder) LessThan(right OperandBuilder) ConditionBuilder {
return LessThan(vb, right)
}
// LessThan returns a ConditionBuilder representing the less than clause of the
// two argument OperandBuilders. The resulting ConditionBuilder can be used as a
// part of other Condition Expressions or as an argument to the WithCondition()
// method for the Builder struct.
//
// Example:
//
// // condition represents the less than clause of the size of the item
// // attribute "foo" and the value 5
// condition := expression.Size(expression.Name("foo")).LessThan(expression.Value(5))
//
// // Used in another Condition Expression
// anotherCondition := expression.Not(condition)
// // Used to make an Builder
// builder := expression.NewBuilder().WithCondition(condition)
//
// Expression Equivalent:
//
// expression.Size(expression.Name("foo")).LessThan(expression.Value(5))
// // Let :five be an ExpressionAttributeValue representing the value 5
// "size (foo) < :five"
func (sb SizeBuilder) LessThan(right OperandBuilder) ConditionBuilder {
return LessThan(sb, right)
}
// LessThanEqual returns a ConditionBuilder representing the less than equal to
// clause of the two argument OperandBuilders. The resulting ConditionBuilder
// can be used as a part of other Condition Expressions or as an argument to the
// WithCondition() method for the Builder struct.
//
// Example:
//
// // condition represents the less than equal to clause of the item
// // attribute "foo" and the value 5
// condition := expression.LessThanEqual(expression.Name("foo"), expression.Value(5))
//
// // Used in another Condition Expression
// anotherCondition := expression.Not(condition)
// // Used to make an Builder
// builder := expression.NewBuilder().WithCondition(condition)
//
// Expression Equivalent:
//
// expression.LessThanEqual(expression.Name("foo"), expression.Value(5))
// // Let :five be an ExpressionAttributeValue representing the value 5
// "foo <= :five"
func LessThanEqual(left, right OperandBuilder) ConditionBuilder {
return ConditionBuilder{
operandList: []OperandBuilder{left, right},
mode: lessThanEqualCond,
}
}
// LessThanEqual returns a ConditionBuilder representing the less than equal to
// clause of the two argument OperandBuilders. The resulting ConditionBuilder
// can be used as a part of other Condition Expressions or as an argument to the
// WithCondition() method for the Builder struct.
//
// Example:
//
// // condition represents the less than equal to clause of the item
// // attribute "foo" and the value 5
// condition := expression.Name("foo").LessThanEqual(expression.Value(5))
//
// // Used in another Condition Expression
// anotherCondition := expression.Not(condition)
// // Used to make an Builder
// builder := expression.NewBuilder().WithCondition(condition)
//
// Expression Equivalent:
//
// expression.Name("foo").LessThanEqual(expression.Value(5))
// // Let :five be an ExpressionAttributeValue representing the value 5
// "foo <= :five"
func (nb NameBuilder) LessThanEqual(right OperandBuilder) ConditionBuilder {
return LessThanEqual(nb, right)
}
// LessThanEqual returns a ConditionBuilder representing the less than equal to
// clause of the two argument OperandBuilders. The resulting ConditionBuilder
// can be used as a part of other Condition Expressions or as an argument to the
// WithCondition() method for the Builder struct.
//
// Example:
//
// // condition represents the less than equal to clause of the item
// // attribute "foo" and the value 5
// condition := expression.Value(5).LessThanEqual(expression.Name("foo"))
//
// // Used in another Condition Expression
// anotherCondition := expression.Not(condition)
// // Used to make an Builder
// builder := expression.NewBuilder().WithCondition(condition)
//
// Expression Equivalent:
//
// expression.Value(5).LessThanEqual(expression.Name("foo"))
// // Let :five be an ExpressionAttributeValue representing the value 5
// ":five <= foo"
func (vb ValueBuilder) LessThanEqual(right OperandBuilder) ConditionBuilder {
return LessThanEqual(vb, right)
}
// LessThanEqual returns a ConditionBuilder representing the less than equal to
// clause of the two argument OperandBuilders. The resulting ConditionBuilder
// can be used as a part of other Condition Expressions or as an argument to the
// WithCondition() method for the Builder struct.
//
// Example:
//
// // condition represents the less than equal to clause of the size of the
// // item attribute "foo" and the value 5
// condition := expression.Size(expression.Name("foo")).LessThanEqual(expression.Value(5))
//
// // Used in another Condition Expression
// anotherCondition := expression.Not(condition)
// // Used to make an Builder
// builder := expression.NewBuilder().WithCondition(condition)
//
// Expression Equivalent:
//
// expression.Size(expression.Name("foo")).LessThanEqual(expression.Value(5))
// // Let :five be an ExpressionAttributeValue representing the value 5
// "size (foo) <= :five"
func (sb SizeBuilder) LessThanEqual(right OperandBuilder) ConditionBuilder {
return LessThanEqual(sb, right)
}
// GreaterThan returns a ConditionBuilder representing the greater than clause
// of the two argument OperandBuilders. The resulting ConditionBuilder can be
// used as a part of other Condition Expressions or as an argument to the
// WithCondition() method for the Builder struct.
//
// Example:
//
// // condition represents the greater than clause of the item attribute
// // "foo" and the value 5
// condition := expression.GreaterThan(expression.Name("foo"), expression.Value(5))
//
// // Used in another Condition Expression
// anotherCondition := expression.Not(condition)
// // Used to make an Builder
// builder := expression.NewBuilder().WithCondition(condition)
//
// Expression Equivalent:
//
// expression.GreaterThan(expression.Name("foo"), expression.Value(5))
// // Let :five be an ExpressionAttributeValue representing the value 5
// "foo > :five"
func GreaterThan(left, right OperandBuilder) ConditionBuilder {
return ConditionBuilder{
operandList: []OperandBuilder{left, right},
mode: greaterThanCond,
}
}
// GreaterThan returns a ConditionBuilder representing the greater than clause
// of the two argument OperandBuilders. The resulting ConditionBuilder can be
// used as a part of other Condition Expressions or as an argument to the
// WithCondition() method for the Builder struct.
//
// Example:
//
// // condition represents the greater than clause of the item attribute
// // "foo" and the value 5
// condition := expression.Name("foo").GreaterThan(expression.Value(5))
//
// // Used in another Condition Expression
// anotherCondition := expression.Not(condition)
// // Used to make an Builder
// builder := expression.NewBuilder().WithCondition(condition)
//
// Expression Equivalent:
//
// expression.Name("foo").GreaterThan(expression.Value(5))
// // Let :five be an ExpressionAttributeValue representing the value 5
// "foo > :five"
func (nb NameBuilder) GreaterThan(right OperandBuilder) ConditionBuilder {
return GreaterThan(nb, right)
}
// GreaterThan returns a ConditionBuilder representing the greater than clause
// of the two argument OperandBuilders. The resulting ConditionBuilder can be
// used as a part of other Condition Expressions or as an argument to the
// WithCondition() method for the Builder struct.
//
// Example:
//
// // condition represents the greater than clause of the item attribute
// // "foo" and the value 5
// condition := expression.Value(5).GreaterThan(expression.Name("foo"))
//
// // Used in another Condition Expression
// anotherCondition := expression.Not(condition)
// // Used to make an Builder
// builder := expression.NewBuilder().WithCondition(condition)
//
// Expression Equivalent:
//
// expression.Value(5).GreaterThan(expression.Name("foo"))
// // Let :five be an ExpressionAttributeValue representing the value 5
// ":five > foo"
func (vb ValueBuilder) GreaterThan(right OperandBuilder) ConditionBuilder {
return GreaterThan(vb, right)
}
// GreaterThan returns a ConditionBuilder representing the greater than
// clause of the two argument OperandBuilders. The resulting ConditionBuilder
// can be used as a part of other Condition Expressions or as an argument to the
// WithCondition() method for the Builder struct.
//
// Example:
//
// // condition represents the greater than clause of the size of the item
// // attribute "foo" and the value 5
// condition := expression.Size(expression.Name("foo")).GreaterThan(expression.Value(5))
//
// // Used in another Condition Expression
// anotherCondition := expression.Not(condition)
// // Used to make an Builder
// builder := expression.NewBuilder().WithCondition(condition)
//
// Expression Equivalent:
//
// expression.Size(expression.Name("foo")).GreaterThan(expression.Value(5))
// // Let :five be an ExpressionAttributeValue representing the value 5
// "size (foo) > :five"
func (sb SizeBuilder) GreaterThan(right OperandBuilder) ConditionBuilder {
return GreaterThan(sb, right)
}
// GreaterThanEqual returns a ConditionBuilder representing the greater than
// equal to clause of the two argument OperandBuilders. The resulting
// ConditionBuilder can be used as a part of other Condition Expressions or as
// an argument to the WithCondition() method for the Builder struct.
//
// Example:
//
// // condition represents the greater than equal to clause of the item
// // attribute "foo" and the value 5
// condition := expression.GreaterThanEqual(expression.Name("foo"), expression.Value(5))
//
// // Used in another Condition Expression
// anotherCondition := expression.Not(condition)
// // Used to make an Builder
// builder := expression.NewBuilder().WithCondition(condition)
//
// Expression Equivalent:
//
// expression.GreaterThanEqual(expression.Name("foo"), expression.Value(5))
// // Let :five be an ExpressionAttributeValue representing the value 5
// "foo >= :five"
func GreaterThanEqual(left, right OperandBuilder) ConditionBuilder {
return ConditionBuilder{
operandList: []OperandBuilder{left, right},
mode: greaterThanEqualCond,
}
}
// GreaterThanEqual returns a ConditionBuilder representing the greater than
// equal to clause of the two argument OperandBuilders. The resulting
// ConditionBuilder can be used as a part of other Condition Expressions or as
// an argument to the WithCondition() method for the Builder struct.
//
// Example:
//
// // condition represents the greater than equal to clause of the item
// // attribute "foo" and the value 5
// condition := expression.Name("foo").GreaterThanEqual(expression.Value(5))
//
// // Used in another Condition Expression
// anotherCondition := expression.Not(condition)
// // Used to make an Builder
// builder := expression.NewBuilder().WithCondition(condition)
//
// Expression Equivalent:
//
// expression.Name("foo").GreaterThanEqual(expression.Value(5))
// // Let :five be an ExpressionAttributeValue representing the value 5
// "foo >= :five"
func (nb NameBuilder) GreaterThanEqual(right OperandBuilder) ConditionBuilder {
return GreaterThanEqual(nb, right)
}
// GreaterThanEqual returns a ConditionBuilder representing the greater than
// equal to clause of the two argument OperandBuilders. The resulting
// ConditionBuilder can be used as a part of other Condition Expressions or as
// an argument to the WithCondition() method for the Builder struct.
//
// Example:
//
// // condition represents the greater than equal to clause of the item
// // attribute "foo" and the value 5
// condition := expression.Value(5).GreaterThanEqual(expression.Name("foo"))
//
// // Used in another Condition Expression
// anotherCondition := expression.Not(condition)
// // Used to make an Builder
// builder := expression.NewBuilder().WithCondition(condition)
//
// Expression Equivalent:
//
// expression.Value(5).GreaterThanEqual(expression.Name("foo"))
// // Let :five be an ExpressionAttributeValue representing the value 5
// ":five >= foo"
func (vb ValueBuilder) GreaterThanEqual(right OperandBuilder) ConditionBuilder {
return GreaterThanEqual(vb, right)
}
// GreaterThanEqual returns a ConditionBuilder representing the greater than
// equal to clause of the two argument OperandBuilders. The resulting
// ConditionBuilder can be used as a part of other Condition Expressions or as
// an argument to the WithCondition() method for the Builder struct.
//
// Example:
//
// // condition represents the greater than equal to clause of the size of
// // the item attribute "foo" and the value 5
// condition := expression.Size(expression.Name("foo")).GreaterThanEqual(expression.Value(5))
//
// // Used in another Condition Expression
// anotherCondition := expression.Not(condition)
// // Used to make an Builder
// builder := expression.NewBuilder().WithCondition(condition)
//
// Expression Equivalent:
//
// expression.Size(expression.Name("foo")).GreaterThanEqual(expression.Value(5))
// // Let :five be an ExpressionAttributeValue representing the value 5
// "size (foo) >= :five"
func (sb SizeBuilder) GreaterThanEqual(right OperandBuilder) ConditionBuilder {
return GreaterThanEqual(sb, right)
}
// And returns a ConditionBuilder representing the logical AND clause of the
// argument ConditionBuilders. The resulting ConditionBuilder can be used as a
// part of other Condition Expressions or as an argument to the WithCondition()
// method for the Builder struct. Note that And() can take a variadic number of
// ConditionBuilders as arguments.
//
// Example:
//
// // condition represents the condition where the item attribute "Name" is
// // equal to value "Generic Name" AND the item attribute "Age" is less
// // than value 40
// condition := expression.And(expression.Name("Name").Equal(expression.Value("Generic Name")), expression.Name("Age").LessThan(expression.Value(40)))
//
// // Used in another Condition Expression
// anotherCondition := expression.Not(condition)
// // Used to make an Builder
// builder := expression.NewBuilder().WithCondition(condition)
//
// Expression Equivalent:
//
// expression.And(expression.Name("Name").Equal(expression.Value("Generic Name")), expression.Name("Age").LessThan(expression.Value(40)))
// // Let #NAME, :name, and :forty be ExpressionAttributeName and
// // ExpressionAttributeValues representing the item attribute "Name", the
// // value "Generic Name", and the value 40
// "(#NAME = :name) AND (Age < :forty)"
func And(left, right ConditionBuilder, other ...ConditionBuilder) ConditionBuilder {
other = append([]ConditionBuilder{left, right}, other...)
return ConditionBuilder{
conditionList: other,
mode: andCond,
}
}
// And returns a ConditionBuilder representing the logical AND clause of the
// argument ConditionBuilders. The resulting ConditionBuilder can be used as a
// part of other Condition Expressions or as an argument to the WithCondition()
// method for the Builder struct. Note that And() can take a variadic number of
// ConditionBuilders as arguments.
//
// Example:
//
// // condition represents the condition where the item attribute "Name" is
// // equal to value "Generic Name" AND the item attribute "Age" is less
// // than value 40
// condition := expression.Name("Name").Equal(expression.Value("Generic Name")).And(expression.Name("Age").LessThan(expression.Value(40)))
//
// // Used in another Condition Expression
// anotherCondition := expression.Not(condition)
// // Used to make an Builder
// builder := expression.NewBuilder().WithCondition(condition)
//
// Expression Equivalent:
//
// expression.Name("Name").Equal(expression.Value("Generic Name")).And(expression.Name("Age").LessThan(expression.Value(40)))
// // Let #NAME, :name, and :forty be ExpressionAttributeName and
// // ExpressionAttributeValues representing the item attribute "Name", the
// // value "Generic Name", and the value 40
// "(#NAME = :name) AND (Age < :forty)"
func (cb ConditionBuilder) And(right ConditionBuilder, other ...ConditionBuilder) ConditionBuilder {
return And(cb, right, other...)
}
// Or returns a ConditionBuilder representing the logical OR clause of the
// argument ConditionBuilders. The resulting ConditionBuilder can be used as a
// part of other Condition Expressions or as an argument to the WithCondition()
// method for the Builder struct. Note that Or() can take a variadic number of
// ConditionBuilders as arguments.
//
// Example:
//
// // condition represents the condition where the item attribute "Price" is
// // less than the value 100 OR the item attribute "Rating" is greater than
// // the value 8
// condition := expression.Or(expression.Name("Price").Equal(expression.Value(100)), expression.Name("Rating").LessThan(expression.Value(8)))
//
// // Used in another Condition Expression
// anotherCondition := expression.Not(condition)
// // Used to make an Builder
// builder := expression.NewBuilder().WithCondition(condition)
//
// Expression Equivalent:
//
// expression.Or(expression.Name("Price").Equal(expression.Value(100)), expression.Name("Rating").LessThan(expression.Value(8)))
// // Let :price and :rating be ExpressionAttributeValues representing the
// // the value 100 and value 8 respectively
// "(Price < :price) OR (Rating > :rating)"
func Or(left, right ConditionBuilder, other ...ConditionBuilder) ConditionBuilder {
other = append([]ConditionBuilder{left, right}, other...)
return ConditionBuilder{
conditionList: other,
mode: orCond,
}
}
// Or returns a ConditionBuilder representing the logical OR clause of the
// argument ConditionBuilders. The resulting ConditionBuilder can be used as a
// part of other Condition Expressions or as an argument to the WithCondition()
// method for the Builder struct. Note that Or() can take a variadic number of
// ConditionBuilders as arguments.
//
// Example:
//
// // condition represents the condition where the item attribute "Price" is
// // less than the value 100 OR the item attribute "Rating" is greater than
// // the value 8
// condition := expression.Name("Price").Equal(expression.Value(100)).Or(expression.Name("Rating").LessThan(expression.Value(8)))
//
// // Used in another Condition Expression
// anotherCondition := expression.Not(condition)
// // Used to make an Builder
// builder := expression.NewBuilder().WithCondition(condition)
//
// Expression Equivalent:
//
// expression.Name("Price").Equal(expression.Value(100)).Or(expression.Name("Rating").LessThan(expression.Value(8)))
// // Let :price and :rating be ExpressionAttributeValues representing the
// // the value 100 and value 8 respectively
// "(Price < :price) OR (Rating > :rating)"
func (cb ConditionBuilder) Or(right ConditionBuilder, other ...ConditionBuilder) ConditionBuilder {
return Or(cb, right, other...)
}
// Not returns a ConditionBuilder representing the logical NOT clause of the
// argument ConditionBuilder. The resulting ConditionBuilder can be used as a
// part of other Condition Expressions or as an argument to the WithCondition()
// method for the Builder struct.
//
// Example:
//
// // condition represents the condition where the item attribute "Name"
// // does not begin with "test"
// condition := expression.Not(expression.Name("Name").BeginsWith("test"))
//
// // Used in another Condition Expression
// anotherCondition := expression.Not(condition)
// // Used to make an Builder
// builder := expression.NewBuilder().WithCondition(condition)
//
// Expression Equivalent:
//
// expression.Not(expression.Name("Name").BeginsWith("test"))
// // Let :prefix be an ExpressionAttributeValue representing the value
// // "test"
// "NOT (begins_with (:prefix))"
func Not(conditionBuilder ConditionBuilder) ConditionBuilder {
return ConditionBuilder{
conditionList: []ConditionBuilder{conditionBuilder},
mode: notCond,
}
}
// Not returns a ConditionBuilder representing the logical NOT clause of the
// argument ConditionBuilder. The resulting ConditionBuilder can be used as a
// part of other Condition Expressions or as an argument to the WithCondition()
// method for the Builder struct.
//
// Example:
//
// // condition represents the condition where the item attribute "Name"
// // does not begin with "test"
// condition := expression.Name("Name").BeginsWith("test").Not()
//
// // Used in another Condition Expression
// anotherCondition := expression.Not(condition)
// // Used to make an Builder
// builder := expression.NewBuilder().WithCondition(condition)
//
// Expression Equivalent:
//
// expression.Name("Name").BeginsWith("test").Not()
// // Let :prefix be an ExpressionAttributeValue representing the value
// // "test"
// "NOT (begins_with (:prefix))"
func (cb ConditionBuilder) Not() ConditionBuilder {
return Not(cb)
}
// Between returns a ConditionBuilder representing the result of the
// BETWEEN function in DynamoDB Condition Expressions. The resulting
// ConditionBuilder can be used as a part of other Condition Expressions or as
// an argument to the WithCondition() method for the Builder struct.
//
// Example:
//
// // condition represents the condition where the value of the item
// // attribute "Rating" is between values 5 and 10
// condition := expression.Between(expression.Name("Rating"), expression.Value(5), expression.Value(10))
//
// // Used in another Condition Expression
// anotherCondition := expression.Not(condition)
// // Used to make an Builder
// builder := expression.NewBuilder().WithCondition(condition)
//
// Expression Equivalent:
//
// expression.Between(expression.Name("Rating"), expression.Value(5), expression.Value(10))
// // Let :five and :ten be ExpressionAttributeValues representing the value
// // 5 and the value 10
// "Rating BETWEEN :five AND :ten"
func Between(op, lower, upper OperandBuilder) ConditionBuilder {
return ConditionBuilder{
operandList: []OperandBuilder{op, lower, upper},
mode: betweenCond,
}
}
// Between returns a ConditionBuilder representing the result of the
// BETWEEN function in DynamoDB Condition Expressions. The resulting
// ConditionBuilder can be used as a part of other Condition Expressions or as
// an argument to the WithCondition() method for the Builder struct.
//
// Example:
//
// // condition represents the condition where the value of the item
// // attribute "Rating" is between values 5 and 10
// condition := expression.Name("Rating").Between(expression.Value(5), expression.Value(10))
//
// // Used in another Condition Expression
// anotherCondition := expression.Not(condition)
// // Used to make an Builder
// builder := expression.NewBuilder().WithCondition(condition)
//
// Expression Equivalent:
//
// expression.Name("Rating").Between(expression.Value(5), expression.Value(10))
// // Let :five and :ten be ExpressionAttributeValues representing the value
// // 5 and the value 10
// "Rating BETWEEN :five AND :ten"
func (nb NameBuilder) Between(lower, upper OperandBuilder) ConditionBuilder {
return Between(nb, lower, upper)
}
// Between returns a ConditionBuilder representing the result of the
// BETWEEN function in DynamoDB Condition Expressions. The resulting
// ConditionBuilder can be used as a part of other Condition Expressions or as
// an argument to the WithCondition() method for the Builder struct.
//
// Example:
//
// // condition represents the condition where the value 6 is between values
// // 5 and 10
// condition := expression.Value(6).Between(expression.Value(5), expression.Value(10))
//
// // Used in another Condition Expression
// anotherCondition := expression.Not(condition)
// // Used to make an Builder
// builder := expression.NewBuilder().WithCondition(condition)
//
// Expression Equivalent:
//
// expression.Value(6).Between(expression.Value(5), expression.Value(10))
// // Let :six, :five and :ten be ExpressionAttributeValues representing the
// // values 6, 5, and 10 respectively
// ":six BETWEEN :five AND :ten"
func (vb ValueBuilder) Between(lower, upper OperandBuilder) ConditionBuilder {
return Between(vb, lower, upper)
}
// Between returns a ConditionBuilder representing the result of the
// BETWEEN function in DynamoDB Condition Expressions. The resulting
// ConditionBuilder can be used as a part of other Condition Expressions or as
// an argument to the WithCondition() method for the Builder struct.
//
// Example:
//
// // condition represents the condition where the size of the item
// // attribute "InviteList" is between values 5 and 10
// condition := expression.Size(expression.Name("InviteList")).Between(expression.Value(5), expression.Value(10))
//
// // Used in another Condition Expression
// anotherCondition := expression.Not(condition)
// // Used to make an Builder
// builder := expression.NewBuilder().WithCondition(condition)
//
// Expression Equivalent:
//
// expression.Size(expression.Name("InviteList")).Between(expression.Value(5), expression.Value(10))
// // Let :five and :ten be ExpressionAttributeValues representing the value
// // 5 and the value 10
// "size (InviteList) BETWEEN :five AND :ten"
func (sb SizeBuilder) Between(lower, upper OperandBuilder) ConditionBuilder {
return Between(sb, lower, upper)
}
// In returns a ConditionBuilder representing the result of the IN function
// in DynamoDB Condition Expressions. The resulting ConditionBuilder can be used
// as a part of other Condition Expressions or as an argument to the
// WithCondition() method for the Builder struct.
//
// Example:
//
// // condition represents the condition where the value of the item