more file structure
This commit is contained in:
@@ -12,22 +12,45 @@ import (
|
||||
|
||||
const create = `-- name: Create :execresult
|
||||
insert into "vm" (
|
||||
"Name", "Vcenter"
|
||||
"Name", "Vcenter", "CreationTime", "ResourcePool", "VmType", "Datacenter", "Cluster", "Folder", "ProvisionedDisk", "InitialVcpus", "InitialRam", "SrmPlaceholder"
|
||||
)
|
||||
values(?, ?)
|
||||
values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
`
|
||||
|
||||
type CreateParams struct {
|
||||
Name sql.NullString
|
||||
Vcenter sql.NullString
|
||||
Name sql.NullString
|
||||
Vcenter sql.NullString
|
||||
CreationTime sql.NullString
|
||||
ResourcePool sql.NullString
|
||||
VmType sql.NullString
|
||||
Datacenter sql.NullString
|
||||
Cluster sql.NullString
|
||||
Folder sql.NullString
|
||||
ProvisionedDisk sql.NullFloat64
|
||||
InitialVcpus sql.NullInt64
|
||||
InitialRam sql.NullInt64
|
||||
SrmPlaceholder sql.NullInt64
|
||||
}
|
||||
|
||||
func (q *Queries) Create(ctx context.Context, arg CreateParams) (sql.Result, error) {
|
||||
return q.db.ExecContext(ctx, create, arg.Name, arg.Vcenter)
|
||||
return q.db.ExecContext(ctx, create,
|
||||
arg.Name,
|
||||
arg.Vcenter,
|
||||
arg.CreationTime,
|
||||
arg.ResourcePool,
|
||||
arg.VmType,
|
||||
arg.Datacenter,
|
||||
arg.Cluster,
|
||||
arg.Folder,
|
||||
arg.ProvisionedDisk,
|
||||
arg.InitialVcpus,
|
||||
arg.InitialRam,
|
||||
arg.SrmPlaceholder,
|
||||
)
|
||||
}
|
||||
|
||||
const get = `-- name: Get :one
|
||||
select Id, Name, Vcenter, CreationTime, DeletionTime, TinRpTime, BronzeRpTime, SilverRpTime, GoldRpTime, ResourcePool, VmType, PoweredOnPct, Datacenter, Cluster, Folder, ProvisionedDisk, InitialVcpus, AvgVcpus, InitialRam, AvgRam, SrmPlaceholder from "vm" where "Name" = ?
|
||||
select Id, Name, Vcenter, CreationTime, DeletionTime, ResourcePool, VmType, Datacenter, Cluster, Folder, ProvisionedDisk, InitialVcpus, InitialRam, SrmPlaceholder from "vm" where "Name" = ?
|
||||
`
|
||||
|
||||
func (q *Queries) Get(ctx context.Context, name sql.NullString) (Vm, error) {
|
||||
@@ -39,28 +62,21 @@ func (q *Queries) Get(ctx context.Context, name sql.NullString) (Vm, error) {
|
||||
&i.Vcenter,
|
||||
&i.CreationTime,
|
||||
&i.DeletionTime,
|
||||
&i.TinRpTime,
|
||||
&i.BronzeRpTime,
|
||||
&i.SilverRpTime,
|
||||
&i.GoldRpTime,
|
||||
&i.ResourcePool,
|
||||
&i.VmType,
|
||||
&i.PoweredOnPct,
|
||||
&i.Datacenter,
|
||||
&i.Cluster,
|
||||
&i.Folder,
|
||||
&i.ProvisionedDisk,
|
||||
&i.InitialVcpus,
|
||||
&i.AvgVcpus,
|
||||
&i.InitialRam,
|
||||
&i.AvgRam,
|
||||
&i.SrmPlaceholder,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const list = `-- name: List :many
|
||||
select Id, Name, Vcenter, CreationTime, DeletionTime, TinRpTime, BronzeRpTime, SilverRpTime, GoldRpTime, ResourcePool, VmType, PoweredOnPct, Datacenter, Cluster, Folder, ProvisionedDisk, InitialVcpus, AvgVcpus, InitialRam, AvgRam, SrmPlaceholder from "vm" order by "Name"
|
||||
select Id, Name, Vcenter, CreationTime, DeletionTime, ResourcePool, VmType, Datacenter, Cluster, Folder, ProvisionedDisk, InitialVcpus, InitialRam, SrmPlaceholder from "vm" order by "Name"
|
||||
`
|
||||
|
||||
func (q *Queries) List(ctx context.Context) ([]Vm, error) {
|
||||
@@ -78,21 +94,14 @@ func (q *Queries) List(ctx context.Context) ([]Vm, error) {
|
||||
&i.Vcenter,
|
||||
&i.CreationTime,
|
||||
&i.DeletionTime,
|
||||
&i.TinRpTime,
|
||||
&i.BronzeRpTime,
|
||||
&i.SilverRpTime,
|
||||
&i.GoldRpTime,
|
||||
&i.ResourcePool,
|
||||
&i.VmType,
|
||||
&i.PoweredOnPct,
|
||||
&i.Datacenter,
|
||||
&i.Cluster,
|
||||
&i.Folder,
|
||||
&i.ProvisionedDisk,
|
||||
&i.InitialVcpus,
|
||||
&i.AvgVcpus,
|
||||
&i.InitialRam,
|
||||
&i.AvgRam,
|
||||
&i.SrmPlaceholder,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
|
Reference in New Issue
Block a user