diff --git a/cmd/open.go b/cmd/open.go index 90c1a67..6fbd4d8 100644 --- a/cmd/open.go +++ b/cmd/open.go @@ -9,6 +9,7 @@ import ( "github.com/spf13/cobra" ) +var dbUser bool var displayTables bool // ---------------------------------------------- @@ -39,6 +40,10 @@ func open(file string) { } switch { + case dbUser: + var user []data.Accounts_User + db.First(&user) + fmt.Println(user[0].Username) case displayTables: tables, err := data.GetTables(*db) if err != nil { @@ -67,5 +72,6 @@ func open(file string) { func init() { rootCmd.AddCommand(openCmd) + openCmd.Flags().BoolVarP(&dbUser, "user", "u", false, "Display database account user") openCmd.Flags().BoolVarP(&displayTables, "tables", "t", false, "Display all database tables") } diff --git a/data/tables.go b/data/tables.go new file mode 100644 index 0000000..12fe685 --- /dev/null +++ b/data/tables.go @@ -0,0 +1,26 @@ +package data + +// ---------------------------------------------- +// table stucts +// ---------------------------------------------- + +type Accounts_User struct { + ID int `gorm:"primaryKey;autoIncrement"` + RemoteID string `json:"remote_id" gorm:"column:remote_id"` + Username string `json:"username" gorm:"column:username"` + FirstName string `json:"first_name" gorm:"column:first_name"` + LastName string `json:"last_name" gorm:"column:last_name"` + Email string `json:"email" gorm:"column:email"` +} + +// ---------------------------------------------- +// table configurations +// ---------------------------------------------- + +type Tabler interface { + TableName() string +} + +func (Accounts_User) TableName() string { + return "accounts_user" +}