This repository was archived by the owner on Feb 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 232
/
Copy pathdatabase.go
60 lines (51 loc) · 2.33 KB
/
database.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
package models
import (
"encoding/json"
"time"
"github.com/featurebasedb/featurebase/v3/dax"
"github.com/gobuffalo/pop/v6"
"github.com/gobuffalo/validate/v3"
)
// Database is used by pop to map your databases database table to your go code.
type Database struct {
// should be DatabaseID, but pop doesn't allow ID to be a custom type
ID string `json:"id" db:"id"`
Name dax.DatabaseName `json:"name" db:"name"`
WorkersMin int `json:"workers_min" db:"workers_min"`
WorkersMax int `json:"workers_max" db:"workers_max"`
Description string `json:"description" db:"description"`
Owner string `json:"owner" db:"owner"`
UpdatedBy string `json:"updated_by" db:"updated_by"`
Tables Tables `json:"tables" has_many:"tables" order_by:"name asc"`
Organization *Organization `json:"organization" belongs_to:"organization"`
OrganizationID string `json:"organization_id" db:"organization_id"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
}
// String is not required by pop and may be deleted
func (d Database) String() string {
jd, _ := json.MarshalIndent(d, " ", " ") //nolint:errchkjson
return string(jd)
}
// Databases is not required by pop and may be deleted
type Databases []Database
// String is not required by pop and may be deleted
func (d Databases) String() string {
jd, _ := json.Marshal(d) //nolint:errchkjson
return string(jd)
}
// Validate gets run every time you call a "pop.Validate*" (pop.ValidateAndSave, pop.ValidateAndCreate, pop.ValidateAndUpdate) method.
// This method is not required and may be deleted.
func (d *Database) Validate(tx *pop.Connection) (*validate.Errors, error) {
return validate.NewErrors(), nil
}
// ValidateCreate gets run every time you call "pop.ValidateAndCreate" method.
// This method is not required and may be deleted.
func (d *Database) ValidateCreate(tx *pop.Connection) (*validate.Errors, error) {
return validate.NewErrors(), nil
}
// ValidateUpdate gets run every time you call "pop.ValidateAndUpdate" method.
// This method is not required and may be deleted.
func (d *Database) ValidateUpdate(tx *pop.Connection) (*validate.Errors, error) {
return validate.NewErrors(), nil
}