47 lines
889 B
Go
47 lines
889 B
Go
package db
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
const createMenuItems = `-- name: CreateMenuItems :exec
|
|
INSERT INTO menu_items(
|
|
location_id,
|
|
name,
|
|
price,
|
|
category,
|
|
description,
|
|
is_available,
|
|
submitted_by
|
|
) values (
|
|
$1, $2, $3, $4, $5, $6, $7
|
|
)
|
|
RETURNING id
|
|
`
|
|
|
|
type CreateMenuItemsParams struct {
|
|
LocationID int32 `json:"location_id"`
|
|
Name string `json:"name"`
|
|
Price int32 `json:"price"`
|
|
Category string `json:"category"`
|
|
Description string `json:"description"`
|
|
IsAvailable bool `json:"is_available"`
|
|
SubmittedBy int32 `json:"submitted_by"`
|
|
}
|
|
|
|
func (q *Queries) CreateMenuItems(ctx context.Context, arg CreateMenuItemsParams) (int32, error) {
|
|
row := q.db.QueryRow(ctx, createMenuItems,
|
|
arg.LocationID,
|
|
arg.Name,
|
|
arg.Price,
|
|
arg.Category,
|
|
arg.Description,
|
|
arg.IsAvailable,
|
|
arg.SubmittedBy,
|
|
)
|
|
|
|
var i int32
|
|
err := row.Scan(&i)
|
|
return i, err
|
|
}
|