/
premis_event_view.go
70 lines (63 loc) · 2.53 KB
/
premis_event_view.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
package pgmodels
import (
"time"
)
var PremisEventFilters = []string{
"date_time__gteq",
"date_time__lteq",
"event_type",
"generic_file_id",
"generic_file_id__is_null",
"generic_file_identifier",
"identifier",
"institution_id",
"intellectual_object_id",
"intellectual_object_identifier",
"outcome",
}
type PremisEventView struct {
tableName struct{} `pg:"premis_events_view"`
ID int64 `json:"id" form:"id"`
Agent string `json:"agent"`
CreatedAt time.Time `json:"created_at"`
DateTime time.Time `json:"date_time"`
Detail string `json:"detail"`
EventType string `json:"event_type"`
GenericFileID int64 `json:"generic_file_id"`
GenericFileIdentifier string `json:"generic_file_identifier"`
Identifier string `json:"identifier"`
InstitutionID int64 `json:"institution_id"`
InstitutionName string `json:"institution_name"`
IntellectualObjectID int64 `json:"intellectual_object_id"`
IntellectualObjectIdentifier string `json:"intellectual_object_identifier"`
Object string `json:"object"`
OldUUID string `json:"old_uuid"`
Outcome string `json:"outcome"`
OutcomeDetail string `json:"outcome_detail"`
OutcomeInformation string `json:"outcome_information"`
UpdatedAt time.Time `json:"updated_at"`
}
// PremisEventViewByID returns the event with the specified id.
// Returns pg.ErrNoRows if there is no match.
func PremisEventViewByID(id int64) (*PremisEventView, error) {
query := NewQuery().Where("id", "=", id)
return PremisEventViewGet(query)
}
// PremisEventViewByIdentifier returns the event with the specified
// identifier. Returns pg.ErrNoRows if there is no match.
func PremisEventViewByIdentifier(identifier string) (*PremisEventView, error) {
query := NewQuery().Where("identifier", "=", identifier)
return PremisEventViewGet(query)
}
// PremisEventViewGet returns the first event matching the query.
func PremisEventViewGet(query *Query) (*PremisEventView, error) {
var event PremisEventView
err := query.Select(&event)
return &event, err
}
// PremisEventViewSelect returns all events matching the query.
func PremisEventViewSelect(query *Query) ([]*PremisEventView, error) {
var events []*PremisEventView
err := query.Select(&events)
return events, err
}