naise_pos/db/sqlc/merchants.sql.go

76 lines
1.6 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.17.2
// source: merchants.sql
package db
import (
"context"
"github.com/google/uuid"
)
const createMerchant = `-- name: CreateMerchant :one
INSERT INTO merchants (name,owner_id)
VALUES ($1, $2)
RETURNING id, index_id, name, owner_id, created_at, updated_at
`
type CreateMerchantParams struct {
Name string `json:"name"`
OwnerID uuid.UUID `json:"owner_id"`
}
func (q *Queries) CreateMerchant(ctx context.Context, arg CreateMerchantParams) (Merchant, error) {
row := q.db.QueryRowContext(ctx, createMerchant, arg.Name, arg.OwnerID)
var i Merchant
err := row.Scan(
&i.ID,
&i.IndexID,
&i.Name,
&i.OwnerID,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}
const getMerchantById = `-- name: GetMerchantById :one
SELECT id, index_id, name, owner_id, created_at, updated_at FROM merchants
WHERE id = $1
`
func (q *Queries) GetMerchantById(ctx context.Context, id uuid.UUID) (Merchant, error) {
row := q.db.QueryRowContext(ctx, getMerchantById, id)
var i Merchant
err := row.Scan(
&i.ID,
&i.IndexID,
&i.Name,
&i.OwnerID,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}
const getMerchantByUserId = `-- name: GetMerchantByUserId :one
SELECT id, index_id, name, owner_id, created_at, updated_at FROM merchants
WHERE owner_id = $1
`
func (q *Queries) GetMerchantByUserId(ctx context.Context, ownerID uuid.UUID) (Merchant, error) {
row := q.db.QueryRowContext(ctx, getMerchantByUserId, ownerID)
var i Merchant
err := row.Scan(
&i.ID,
&i.IndexID,
&i.Name,
&i.OwnerID,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}