This repository was archived by the owner on Sep 9, 2024. It is now read-only.
forked from gocassa/gocassa
-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathmap_table.go
More file actions
52 lines (44 loc) · 1.36 KB
/
map_table.go
File metadata and controls
52 lines (44 loc) · 1.36 KB
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
package gocassa
type mapT struct {
t Table
idField string
}
func (m *mapT) Table() Table { return m.t }
func (m *mapT) Create() error { return m.Table().Create() }
func (m *mapT) CreateIfNotExist() error { return m.Table().CreateIfNotExist() }
func (m *mapT) Name() string { return m.Table().Name() }
func (m *mapT) Recreate() error { return m.Table().Recreate() }
func (m *mapT) CreateStatement() (Statement, error) { return m.Table().CreateStatement() }
func (m *mapT) CreateIfNotExistStatement() (Statement, error) {
return m.Table().CreateIfNotExistStatement()
}
func (m *mapT) Update(id interface{}, ma map[string]interface{}) Op {
return m.Table().
Where(Eq(m.idField, id)).
Update(ma)
}
func (m *mapT) Set(v interface{}) Op {
return m.Table().
Set(v)
}
func (m *mapT) Delete(id interface{}) Op {
return m.Table().
Where(Eq(m.idField, id)).
Delete()
}
func (m *mapT) Read(id, pointer interface{}) Op {
return m.Table().
Where(Eq(m.idField, id)).
ReadOne(pointer)
}
func (m *mapT) MultiRead(ids []interface{}, pointerToASlice interface{}) Op {
return m.Table().
Where(In(m.idField, ids...)).
Read(pointerToASlice)
}
func (m *mapT) WithOptions(o Options) MapTable {
return &mapT{
t: m.Table().WithOptions(o),
idField: m.idField,
}
}