-
Notifications
You must be signed in to change notification settings - Fork 7
/
query.go
56 lines (48 loc) · 1.32 KB
/
query.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
package main
// CreateTableQuery represents a DDL (Data Definition Language) query to create
// new table.
type CreateTableQuery struct {
TableName string
Columns []struct {
Name string
Type string
}
}
// SelectQuery is a DQL (Data Query Language) query for fetching data from the database.
type SelectQuery struct {
From string
Where []WhereExpression
}
// Operand is an operand in WHERE expression
type Operand struct {
Value interface{}
Type string // identifier or value
}
// WhereExpression represents WHERE part expressions of the SQL query.
type WhereExpression struct {
Left Operand
Operation string
Right Operand
}
// InsertQuery is a DML (Data Manipulation Language) query for inserting data into the database.
type InsertQuery struct {
TableName string
Columns []string
Values [][]interface{}
}
// UpdateQuery is a DML (Data Manipulation Language) query for updating data in the database.
type UpdateQuery struct {
TableName string
Where []WhereExpression
Set []SetExpression
}
// SetExpression represents the SET part in the UPDATE SQL query.
type SetExpression struct {
Column string
Value interface{}
}
// DeleteQuery is a DML (Data Manipulation Language) query for deleting data from the database.
type DeleteQuery struct {
TableName string
Where []WhereExpression
}