Files
OwnCord/Server/db/dbgen/plugins.sql.go
T

170 lines
4.2 KiB
Go
Raw Normal View History

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.30.0
// source: plugins.sql
package dbgen
import (
"context"
"database/sql"
)
const disablePlugin = `-- name: DisablePlugin :exec
UPDATE plugins SET enabled = 0 WHERE id = ?
`
func (q *Queries) DisablePlugin(ctx context.Context, id int64) error {
_, err := q.db.ExecContext(ctx, disablePlugin, id)
return err
}
const enablePlugin = `-- name: EnablePlugin :exec
UPDATE plugins SET enabled = 1 WHERE id = ?
`
func (q *Queries) EnablePlugin(ctx context.Context, id int64) error {
_, err := q.db.ExecContext(ctx, enablePlugin, id)
return err
}
const getPlugin = `-- name: GetPlugin :one
SELECT id, name, version, enabled, manifest_json, installed_at FROM plugins WHERE id = ?
`
func (q *Queries) GetPlugin(ctx context.Context, id int64) (Plugin, error) {
row := q.db.QueryRowContext(ctx, getPlugin, id)
var i Plugin
err := row.Scan(
&i.ID,
&i.Name,
&i.Version,
&i.Enabled,
&i.ManifestJson,
&i.InstalledAt,
)
return i, err
}
const getPluginByName = `-- name: GetPluginByName :one
SELECT id, name, version, enabled, manifest_json, installed_at FROM plugins WHERE name = ?
`
func (q *Queries) GetPluginByName(ctx context.Context, name string) (Plugin, error) {
row := q.db.QueryRowContext(ctx, getPluginByName, name)
var i Plugin
err := row.Scan(
&i.ID,
&i.Name,
&i.Version,
&i.Enabled,
&i.ManifestJson,
&i.InstalledAt,
)
return i, err
}
const installPlugin = `-- name: InstallPlugin :execresult
INSERT INTO plugins (name, version, manifest_json) VALUES (?, ?, ?)
ON CONFLICT(name) DO UPDATE SET version = excluded.version, manifest_json = excluded.manifest_json
`
type InstallPluginParams struct {
Name string `json:"name"`
Version string `json:"version"`
ManifestJson string `json:"manifestJson"`
}
func (q *Queries) InstallPlugin(ctx context.Context, arg InstallPluginParams) (sql.Result, error) {
return q.db.ExecContext(ctx, installPlugin, arg.Name, arg.Version, arg.ManifestJson)
}
const listPlugins = `-- name: ListPlugins :many
SELECT id, name, version, enabled, manifest_json, installed_at FROM plugins ORDER BY name
`
func (q *Queries) ListPlugins(ctx context.Context) ([]Plugin, error) {
rows, err := q.db.QueryContext(ctx, listPlugins)
if err != nil {
return nil, err
}
defer rows.Close()
items := []Plugin{}
for rows.Next() {
var i Plugin
if err := rows.Scan(
&i.ID,
&i.Name,
&i.Version,
&i.Enabled,
&i.ManifestJson,
&i.InstalledAt,
); 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 pluginKVDelete = `-- name: PluginKVDelete :exec
DELETE FROM plugin_kv WHERE plugin_id = ? AND key = ?
`
type PluginKVDeleteParams struct {
PluginID int64 `json:"pluginId"`
Key string `json:"key"`
}
func (q *Queries) PluginKVDelete(ctx context.Context, arg PluginKVDeleteParams) error {
_, err := q.db.ExecContext(ctx, pluginKVDelete, arg.PluginID, arg.Key)
return err
}
const pluginKVGet = `-- name: PluginKVGet :one
SELECT value FROM plugin_kv WHERE plugin_id = ? AND key = ?
`
type PluginKVGetParams struct {
PluginID int64 `json:"pluginId"`
Key string `json:"key"`
}
func (q *Queries) PluginKVGet(ctx context.Context, arg PluginKVGetParams) ([]byte, error) {
row := q.db.QueryRowContext(ctx, pluginKVGet, arg.PluginID, arg.Key)
var value []byte
err := row.Scan(&value)
return value, err
}
const pluginKVSet = `-- name: PluginKVSet :exec
INSERT INTO plugin_kv (plugin_id, key, value) VALUES (?, ?, ?)
ON CONFLICT(plugin_id, key) DO UPDATE SET value = excluded.value
`
type PluginKVSetParams struct {
PluginID int64 `json:"pluginId"`
Key string `json:"key"`
Value []byte `json:"value"`
}
func (q *Queries) PluginKVSet(ctx context.Context, arg PluginKVSetParams) error {
_, err := q.db.ExecContext(ctx, pluginKVSet, arg.PluginID, arg.Key, arg.Value)
return err
}
const uninstallPlugin = `-- name: UninstallPlugin :exec
DELETE FROM plugins WHERE id = ?
`
func (q *Queries) UninstallPlugin(ctx context.Context, id int64) error {
_, err := q.db.ExecContext(ctx, uninstallPlugin, id)
return err
}