V3 version with backward comp
This commit is contained in:
@@ -0,0 +1,144 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.31.1
|
||||
// source: retention_policies.sql
|
||||
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
const createRetentionPolicy = `-- name: CreateRetentionPolicy :one
|
||||
INSERT INTO retention_policies (user_id, storage_location_id, rule_type, rule_value)
|
||||
VALUES ($1, $2, $3, $4)
|
||||
RETURNING id, user_id, storage_location_id, rule_type, rule_value, created_at
|
||||
`
|
||||
|
||||
type CreateRetentionPolicyParams struct {
|
||||
UserID uuid.UUID `json:"user_id"`
|
||||
StorageLocationID uuid.UUID `json:"storage_location_id"`
|
||||
RuleType string `json:"rule_type"`
|
||||
RuleValue json.RawMessage `json:"rule_value"`
|
||||
}
|
||||
|
||||
func (q *Queries) CreateRetentionPolicy(ctx context.Context, arg CreateRetentionPolicyParams) (RetentionPolicy, error) {
|
||||
row := q.db.QueryRowContext(ctx, createRetentionPolicy,
|
||||
arg.UserID,
|
||||
arg.StorageLocationID,
|
||||
arg.RuleType,
|
||||
arg.RuleValue,
|
||||
)
|
||||
var i RetentionPolicy
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.UserID,
|
||||
&i.StorageLocationID,
|
||||
&i.RuleType,
|
||||
&i.RuleValue,
|
||||
&i.CreatedAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const deleteRetentionPolicy = `-- name: DeleteRetentionPolicy :exec
|
||||
DELETE FROM retention_policies
|
||||
WHERE id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) DeleteRetentionPolicy(ctx context.Context, id uuid.UUID) error {
|
||||
_, err := q.db.ExecContext(ctx, deleteRetentionPolicy, id)
|
||||
return err
|
||||
}
|
||||
|
||||
const getRetentionPolicy = `-- name: GetRetentionPolicy :one
|
||||
SELECT id, user_id, storage_location_id, rule_type, rule_value, created_at FROM retention_policies
|
||||
WHERE id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetRetentionPolicy(ctx context.Context, id uuid.UUID) (RetentionPolicy, error) {
|
||||
row := q.db.QueryRowContext(ctx, getRetentionPolicy, id)
|
||||
var i RetentionPolicy
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.UserID,
|
||||
&i.StorageLocationID,
|
||||
&i.RuleType,
|
||||
&i.RuleValue,
|
||||
&i.CreatedAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const listRetentionPoliciesByLocation = `-- name: ListRetentionPoliciesByLocation :many
|
||||
SELECT id, user_id, storage_location_id, rule_type, rule_value, created_at FROM retention_policies
|
||||
WHERE storage_location_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) ListRetentionPoliciesByLocation(ctx context.Context, storageLocationID uuid.UUID) ([]RetentionPolicy, error) {
|
||||
rows, err := q.db.QueryContext(ctx, listRetentionPoliciesByLocation, storageLocationID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []RetentionPolicy
|
||||
for rows.Next() {
|
||||
var i RetentionPolicy
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.UserID,
|
||||
&i.StorageLocationID,
|
||||
&i.RuleType,
|
||||
&i.RuleValue,
|
||||
&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 listRetentionPoliciesByUser = `-- name: ListRetentionPoliciesByUser :many
|
||||
SELECT id, user_id, storage_location_id, rule_type, rule_value, created_at FROM retention_policies
|
||||
WHERE user_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) ListRetentionPoliciesByUser(ctx context.Context, userID uuid.UUID) ([]RetentionPolicy, error) {
|
||||
rows, err := q.db.QueryContext(ctx, listRetentionPoliciesByUser, userID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []RetentionPolicy
|
||||
for rows.Next() {
|
||||
var i RetentionPolicy
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.UserID,
|
||||
&i.StorageLocationID,
|
||||
&i.RuleType,
|
||||
&i.RuleValue,
|
||||
&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
|
||||
}
|
||||
Reference in New Issue
Block a user