github.com/ydb-platform/ydb-go-sdk/v3@v3.57.0/internal/params/optional.go (about) 1 package params 2 3 import ( 4 "time" 5 6 "github.com/ydb-platform/ydb-go-sdk/v3/internal/value" 7 ) 8 9 type ( 10 optional struct { 11 parent Builder 12 name string 13 value value.Value 14 } 15 optionalBuilder struct { 16 opt *optional 17 } 18 ) 19 20 func (b *optionalBuilder) Build() Builder { 21 b.opt.parent.params = append(b.opt.parent.params, &Parameter{ 22 parent: b.opt.parent, 23 name: b.opt.name, 24 value: value.OptionalValue(b.opt.value), 25 }) 26 27 return b.opt.parent 28 } 29 30 func (p *optional) Text(v string) *optionalBuilder { 31 p.value = value.TextValue(v) 32 33 return &optionalBuilder{opt: p} 34 } 35 36 func (p *optional) Bytes(v []byte) *optionalBuilder { 37 p.value = value.BytesValue(v) 38 39 return &optionalBuilder{opt: p} 40 } 41 42 func (p *optional) Bool(v bool) *optionalBuilder { 43 p.value = value.BoolValue(v) 44 45 return &optionalBuilder{opt: p} 46 } 47 48 func (p *optional) Uint64(v uint64) *optionalBuilder { 49 p.value = value.Uint64Value(v) 50 51 return &optionalBuilder{opt: p} 52 } 53 54 func (p *optional) Int64(v int64) *optionalBuilder { 55 p.value = value.Int64Value(v) 56 57 return &optionalBuilder{opt: p} 58 } 59 60 func (p *optional) Uint32(v uint32) *optionalBuilder { 61 p.value = value.Uint32Value(v) 62 63 return &optionalBuilder{opt: p} 64 } 65 66 func (p *optional) Int32(v int32) *optionalBuilder { 67 p.value = value.Int32Value(v) 68 69 return &optionalBuilder{opt: p} 70 } 71 72 func (p *optional) Uint16(v uint16) *optionalBuilder { 73 p.value = value.Uint16Value(v) 74 75 return &optionalBuilder{opt: p} 76 } 77 78 func (p *optional) Int16(v int16) *optionalBuilder { 79 p.value = value.Int16Value(v) 80 81 return &optionalBuilder{opt: p} 82 } 83 84 func (p *optional) Uint8(v uint8) *optionalBuilder { 85 p.value = value.Uint8Value(v) 86 87 return &optionalBuilder{opt: p} 88 } 89 90 func (p *optional) Int8(v int8) *optionalBuilder { 91 p.value = value.Int8Value(v) 92 93 return &optionalBuilder{opt: p} 94 } 95 96 func (p *optional) Float(v float32) *optionalBuilder { 97 p.value = value.FloatValue(v) 98 99 return &optionalBuilder{opt: p} 100 } 101 102 func (p *optional) Double(v float64) *optionalBuilder { 103 p.value = value.DoubleValue(v) 104 105 return &optionalBuilder{opt: p} 106 } 107 108 func (p *optional) Decimal(v [16]byte, precision, scale uint32) *optionalBuilder { 109 p.value = value.DecimalValue(v, precision, scale) 110 111 return &optionalBuilder{opt: p} 112 } 113 114 func (p *optional) Timestamp(v time.Time) *optionalBuilder { 115 p.value = value.TimestampValueFromTime(v) 116 117 return &optionalBuilder{opt: p} 118 } 119 120 func (p *optional) Date(v time.Time) *optionalBuilder { 121 p.value = value.DateValueFromTime(v) 122 123 return &optionalBuilder{opt: p} 124 } 125 126 func (p *optional) Datetime(v time.Time) *optionalBuilder { 127 p.value = value.DatetimeValueFromTime(v) 128 129 return &optionalBuilder{opt: p} 130 } 131 132 func (p *optional) Interval(v time.Duration) *optionalBuilder { 133 p.value = value.IntervalValueFromDuration(v) 134 135 return &optionalBuilder{opt: p} 136 } 137 138 func (p *optional) JSON(v string) *optionalBuilder { 139 p.value = value.JSONValue(v) 140 141 return &optionalBuilder{opt: p} 142 } 143 144 func (p *optional) JSONDocument(v string) *optionalBuilder { 145 p.value = value.JSONDocumentValue(v) 146 147 return &optionalBuilder{opt: p} 148 } 149 150 func (p *optional) YSON(v []byte) *optionalBuilder { 151 p.value = value.YSONValue(v) 152 153 return &optionalBuilder{opt: p} 154 } 155 156 func (p *optional) UUID(v [16]byte) *optionalBuilder { 157 p.value = value.UUIDValue(v) 158 159 return &optionalBuilder{opt: p} 160 }