// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.29.0 // source: boxes.sql package db import ( "context" "database/sql" ) const createBox = `-- name: CreateBox :execresult INSERT INTO boxes ( shipment_id, length, width, height, weight ) VALUES ( ?, ?, ?, ?, ? ) ` type CreateBoxParams struct { ShipmentID int32 `json:"shipment_id"` Length string `json:"length"` Width string `json:"width"` Height string `json:"height"` Weight string `json:"weight"` } func (q *Queries) CreateBox(ctx context.Context, arg CreateBoxParams) (sql.Result, error) { return q.db.ExecContext(ctx, createBox, arg.ShipmentID, arg.Length, arg.Width, arg.Height, arg.Weight, ) } const deleteBox = `-- name: DeleteBox :exec DELETE FROM boxes WHERE id = ? ` func (q *Queries) DeleteBox(ctx context.Context, id int32) error { _, err := q.db.ExecContext(ctx, deleteBox, id) return err } const getBox = `-- name: GetBox :one SELECT id, shipment_id, length, width, height, weight FROM boxes WHERE id = ? LIMIT 1 ` func (q *Queries) GetBox(ctx context.Context, id int32) (Box, error) { row := q.db.QueryRowContext(ctx, getBox, id) var i Box err := row.Scan( &i.ID, &i.ShipmentID, &i.Length, &i.Width, &i.Height, &i.Weight, ) return i, err } const listBoxes = `-- name: ListBoxes :many SELECT id, shipment_id, length, width, height, weight FROM boxes ORDER BY id DESC LIMIT ? OFFSET ? ` type ListBoxesParams struct { Limit int32 `json:"limit"` Offset int32 `json:"offset"` } func (q *Queries) ListBoxes(ctx context.Context, arg ListBoxesParams) ([]Box, error) { rows, err := q.db.QueryContext(ctx, listBoxes, arg.Limit, arg.Offset) if err != nil { return nil, err } defer rows.Close() items := []Box{} for rows.Next() { var i Box if err := rows.Scan( &i.ID, &i.ShipmentID, &i.Length, &i.Width, &i.Height, &i.Weight, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Close(); err != nil { return nil, err } if err := rows.Err(); err != nil { return nil, err } return items, nil } const listBoxesByShipment = `-- name: ListBoxesByShipment :many SELECT id, shipment_id, length, width, height, weight FROM boxes WHERE shipment_id = ? ORDER BY id ` func (q *Queries) ListBoxesByShipment(ctx context.Context, shipmentID int32) ([]Box, error) { rows, err := q.db.QueryContext(ctx, listBoxesByShipment, shipmentID) if err != nil { return nil, err } defer rows.Close() items := []Box{} for rows.Next() { var i Box if err := rows.Scan( &i.ID, &i.ShipmentID, &i.Length, &i.Width, &i.Height, &i.Weight, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Close(); err != nil { return nil, err } if err := rows.Err(); err != nil { return nil, err } return items, nil } const updateBox = `-- name: UpdateBox :exec UPDATE boxes SET length = ?, width = ?, height = ?, weight = ? WHERE id = ? ` type UpdateBoxParams struct { Length string `json:"length"` Width string `json:"width"` Height string `json:"height"` Weight string `json:"weight"` ID int32 `json:"id"` } func (q *Queries) UpdateBox(ctx context.Context, arg UpdateBoxParams) error { _, err := q.db.ExecContext(ctx, updateBox, arg.Length, arg.Width, arg.Height, arg.Weight, arg.ID, ) return err }