mirror of
https://github.com/MizuchiLabs/mantrae.git
synced 2025-12-16 20:05:17 -06:00
157 lines
3.2 KiB
Go
157 lines
3.2 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.30.0
|
|
// source: errors.sql
|
|
|
|
package db
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
const deleteErrorById = `-- name: DeleteErrorById :exec
|
|
DELETE FROM errors
|
|
WHERE
|
|
id = ?
|
|
`
|
|
|
|
func (q *Queries) DeleteErrorById(ctx context.Context, id int64) error {
|
|
_, err := q.exec(ctx, q.deleteErrorByIdStmt, deleteErrorById, id)
|
|
return err
|
|
}
|
|
|
|
const deleteErrorsByProfile = `-- name: DeleteErrorsByProfile :exec
|
|
DELETE FROM errors
|
|
WHERE
|
|
profile_id = ?
|
|
`
|
|
|
|
func (q *Queries) DeleteErrorsByProfile(ctx context.Context, profileID int64) error {
|
|
_, err := q.exec(ctx, q.deleteErrorsByProfileStmt, deleteErrorsByProfile, profileID)
|
|
return err
|
|
}
|
|
|
|
const deleteErrorsByProfileCategory = `-- name: DeleteErrorsByProfileCategory :exec
|
|
DELETE FROM errors
|
|
WHERE
|
|
profile_id = ?
|
|
AND category = ?
|
|
`
|
|
|
|
type DeleteErrorsByProfileCategoryParams struct {
|
|
ProfileID int64 `json:"profileId"`
|
|
Category string `json:"category"`
|
|
}
|
|
|
|
func (q *Queries) DeleteErrorsByProfileCategory(ctx context.Context, arg DeleteErrorsByProfileCategoryParams) error {
|
|
_, err := q.exec(ctx, q.deleteErrorsByProfileCategoryStmt, deleteErrorsByProfileCategory, arg.ProfileID, arg.Category)
|
|
return err
|
|
}
|
|
|
|
const getErrorsByProfile = `-- name: GetErrorsByProfile :many
|
|
SELECT
|
|
id, profile_id, category, message, details, created_at
|
|
FROM
|
|
errors
|
|
WHERE
|
|
profile_id = ?
|
|
ORDER BY
|
|
created_at DESC
|
|
`
|
|
|
|
func (q *Queries) GetErrorsByProfile(ctx context.Context, profileID int64) ([]Error, error) {
|
|
rows, err := q.query(ctx, q.getErrorsByProfileStmt, getErrorsByProfile, profileID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []Error
|
|
for rows.Next() {
|
|
var i Error
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.ProfileID,
|
|
&i.Category,
|
|
&i.Message,
|
|
&i.Details,
|
|
&i.CreatedAt,
|
|
); 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 listErrors = `-- name: ListErrors :many
|
|
SELECT
|
|
id, profile_id, category, message, details, created_at
|
|
FROM
|
|
errors
|
|
ORDER BY
|
|
created_at DESC
|
|
`
|
|
|
|
func (q *Queries) ListErrors(ctx context.Context) ([]Error, error) {
|
|
rows, err := q.query(ctx, q.listErrorsStmt, listErrors)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []Error
|
|
for rows.Next() {
|
|
var i Error
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.ProfileID,
|
|
&i.Category,
|
|
&i.Message,
|
|
&i.Details,
|
|
&i.CreatedAt,
|
|
); 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 logError = `-- name: LogError :exec
|
|
INSERT INTO
|
|
errors (profile_id, category, message, details)
|
|
VALUES
|
|
(?, ?, ?, ?) ON CONFLICT (profile_id, category, details) DO
|
|
UPDATE
|
|
SET
|
|
created_at = CURRENT_TIMESTAMP
|
|
`
|
|
|
|
type LogErrorParams struct {
|
|
ProfileID int64 `json:"profileId"`
|
|
Category string `json:"category"`
|
|
Message string `json:"message"`
|
|
Details *string `json:"details"`
|
|
}
|
|
|
|
func (q *Queries) LogError(ctx context.Context, arg LogErrorParams) error {
|
|
_, err := q.exec(ctx, q.logErrorStmt, logError,
|
|
arg.ProfileID,
|
|
arg.Category,
|
|
arg.Message,
|
|
arg.Details,
|
|
)
|
|
return err
|
|
}
|