2023-03-05 23:35:41 +07:00
|
|
|
// Code generated by sqlc. DO NOT EDIT.
|
|
|
|
// versions:
|
|
|
|
// sqlc v1.17.2
|
2023-03-13 09:24:59 +07:00
|
|
|
// source: merchants.sql
|
2023-03-05 23:35:41 +07:00
|
|
|
|
|
|
|
package db
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"github.com/google/uuid"
|
|
|
|
)
|
|
|
|
|
2023-03-13 09:24:59 +07:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2023-03-05 23:35:41 +07:00
|
|
|
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
|
|
|
|
}
|