-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfieldvalue.go
88 lines (78 loc) · 2.36 KB
/
fieldvalue.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
// Package builder provides a fluent SQL query builder with support for multiple SQL dialects.
package builder
// // Field ...
// type Field struct {
// Name string
// }
// func (f *Field) String() string {
// return f.Name
// }
// func (f *Field) methodName() {
// }
// // NewField return an new Field
// func NewField(name string) Field {
// return Field{
// Name: name,
// }
// }
// FieldValue represents a field-value pair used in SQL queries for setting values
// in INSERT, UPDATE, and other operations. It provides a convenient way to associate
// a field name with its corresponding value while maintaining type safety.
type FieldValue struct {
// Name is the name of the database field or column
Name string
// Value is the value to be assigned to the field, can be of any type
Value interface{}
}
// NewFieldValue creates a new FieldValue instance with the specified field name and value.
// It is the primary constructor for creating field-value pairs.
//
// Parameters:
// - name: The name of the database field or column
// - value: The value to be assigned to the field
//
// Returns:
// - *FieldValue: A pointer to the newly created FieldValue instance
//
// Example:
//
// fv := NewFieldValue("age", 25)
// b.Update("users").Set(fv)
func NewFieldValue(name string, value interface{}) *FieldValue {
return &FieldValue{
Name: name,
Value: value,
}
}
// NewFV is a shorthand alias for NewFieldValue. It creates a new FieldValue instance
// with the specified field name and value.
//
// Parameters:
// - name: The name of the database field or column
// - value: The value to be assigned to the field
//
// Returns:
// - *FieldValue: A pointer to the newly created FieldValue instance
//
// Example:
//
// fv := NewFV("status", "active")
func NewFV(name string, value interface{}) *FieldValue {
return NewFieldValue(name, value)
}
// NewKV is a shorthand alias for NewFieldValue. It creates a new FieldValue instance
// with the specified field name and value. The name 'KV' stands for 'Key-Value'.
//
// Parameters:
// - name: The name of the database field or column
// - value: The value to be assigned to the field
//
// Returns:
// - *FieldValue: A pointer to the newly created FieldValue instance
//
// Example:
//
// fv := NewKV("email", "[email protected]")
func NewKV(name string, value interface{}) *FieldValue {
return NewFieldValue(name, value)
}