mirror of
https://github.com/J3vb/OwnCord.git
synced 2026-09-03 03:50:00 +03:00
134 lines
3.4 KiB
Go
134 lines
3.4 KiB
Go
// 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 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
|
||
|
|
}
|