Files
motr/internal/db/users/query.sql.go
Prad Nukala 8ad936cfc7 feat/wasi plugins (#13)
* feat: migrate build system to Taskfile for improved automation

* refactor: consolidate build tasks for improved maintainability

* build: pin sqlc version to v1.28.0

* refactor: streamline local development environment
2025-06-06 01:33:09 -04:00

1178 lines
27 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.28.0
// source: query.sql
package users
import (
"context"
)
const checkHandleExists = `-- name: CheckHandleExists :one
SELECT COUNT(*) > 0 as handle_exists FROM profiles
WHERE handle = ?
AND deleted_at IS NULL
`
func (q *Queries) CheckHandleExists(ctx context.Context, handle string) (bool, error) {
row := q.db.QueryRowContext(ctx, checkHandleExists, handle)
var handle_exists bool
err := row.Scan(&handle_exists)
return handle_exists, err
}
const getAccountByAddress = `-- name: GetAccountByAddress :one
SELECT id, created_at, updated_at, deleted_at, number, sequence, address, public_key, chain_id, block_created, controller, label, handle, is_subsidiary, is_validator, is_delegator, is_accountable FROM accounts
WHERE address = ? AND deleted_at IS NULL
LIMIT 1
`
func (q *Queries) GetAccountByAddress(ctx context.Context, address string) (Account, error) {
row := q.db.QueryRowContext(ctx, getAccountByAddress, address)
var i Account
err := row.Scan(
&i.ID,
&i.CreatedAt,
&i.UpdatedAt,
&i.DeletedAt,
&i.Number,
&i.Sequence,
&i.Address,
&i.PublicKey,
&i.ChainID,
&i.BlockCreated,
&i.Controller,
&i.Label,
&i.Handle,
&i.IsSubsidiary,
&i.IsValidator,
&i.IsDelegator,
&i.IsAccountable,
)
return i, err
}
const getAccountByController = `-- name: GetAccountByController :one
SELECT id, created_at, updated_at, deleted_at, number, sequence, address, public_key, chain_id, block_created, controller, label, handle, is_subsidiary, is_validator, is_delegator, is_accountable FROM accounts
WHERE controller = ? AND deleted_at IS NULL
LIMIT 1
`
func (q *Queries) GetAccountByController(ctx context.Context, controller string) (Account, error) {
row := q.db.QueryRowContext(ctx, getAccountByController, controller)
var i Account
err := row.Scan(
&i.ID,
&i.CreatedAt,
&i.UpdatedAt,
&i.DeletedAt,
&i.Number,
&i.Sequence,
&i.Address,
&i.PublicKey,
&i.ChainID,
&i.BlockCreated,
&i.Controller,
&i.Label,
&i.Handle,
&i.IsSubsidiary,
&i.IsValidator,
&i.IsDelegator,
&i.IsAccountable,
)
return i, err
}
const getAccountByID = `-- name: GetAccountByID :one
SELECT id, created_at, updated_at, deleted_at, number, sequence, address, public_key, chain_id, block_created, controller, label, handle, is_subsidiary, is_validator, is_delegator, is_accountable FROM accounts
WHERE id = ? AND deleted_at IS NULL
LIMIT 1
`
func (q *Queries) GetAccountByID(ctx context.Context, id string) (Account, error) {
row := q.db.QueryRowContext(ctx, getAccountByID, id)
var i Account
err := row.Scan(
&i.ID,
&i.CreatedAt,
&i.UpdatedAt,
&i.DeletedAt,
&i.Number,
&i.Sequence,
&i.Address,
&i.PublicKey,
&i.ChainID,
&i.BlockCreated,
&i.Controller,
&i.Label,
&i.Handle,
&i.IsSubsidiary,
&i.IsValidator,
&i.IsDelegator,
&i.IsAccountable,
)
return i, err
}
const getAccountByNumber = `-- name: GetAccountByNumber :one
SELECT id, created_at, updated_at, deleted_at, number, sequence, address, public_key, chain_id, block_created, controller, label, handle, is_subsidiary, is_validator, is_delegator, is_accountable FROM accounts
WHERE number = ? AND deleted_at IS NULL
LIMIT 1
`
func (q *Queries) GetAccountByNumber(ctx context.Context, number int64) (Account, error) {
row := q.db.QueryRowContext(ctx, getAccountByNumber, number)
var i Account
err := row.Scan(
&i.ID,
&i.CreatedAt,
&i.UpdatedAt,
&i.DeletedAt,
&i.Number,
&i.Sequence,
&i.Address,
&i.PublicKey,
&i.ChainID,
&i.BlockCreated,
&i.Controller,
&i.Label,
&i.Handle,
&i.IsSubsidiary,
&i.IsValidator,
&i.IsDelegator,
&i.IsAccountable,
)
return i, err
}
const getAccountByPublicKey = `-- name: GetAccountByPublicKey :one
SELECT id, created_at, updated_at, deleted_at, number, sequence, address, public_key, chain_id, block_created, controller, label, handle, is_subsidiary, is_validator, is_delegator, is_accountable FROM accounts
WHERE public_key = ? AND deleted_at IS NULL
LIMIT 1
`
func (q *Queries) GetAccountByPublicKey(ctx context.Context, publicKey string) (Account, error) {
row := q.db.QueryRowContext(ctx, getAccountByPublicKey, publicKey)
var i Account
err := row.Scan(
&i.ID,
&i.CreatedAt,
&i.UpdatedAt,
&i.DeletedAt,
&i.Number,
&i.Sequence,
&i.Address,
&i.PublicKey,
&i.ChainID,
&i.BlockCreated,
&i.Controller,
&i.Label,
&i.Handle,
&i.IsSubsidiary,
&i.IsValidator,
&i.IsDelegator,
&i.IsAccountable,
)
return i, err
}
const getAccountBySequence = `-- name: GetAccountBySequence :one
SELECT id, created_at, updated_at, deleted_at, number, sequence, address, public_key, chain_id, block_created, controller, label, handle, is_subsidiary, is_validator, is_delegator, is_accountable FROM accounts
WHERE sequence = ? AND deleted_at IS NULL
LIMIT 1
`
func (q *Queries) GetAccountBySequence(ctx context.Context, sequence int64) (Account, error) {
row := q.db.QueryRowContext(ctx, getAccountBySequence, sequence)
var i Account
err := row.Scan(
&i.ID,
&i.CreatedAt,
&i.UpdatedAt,
&i.DeletedAt,
&i.Number,
&i.Sequence,
&i.Address,
&i.PublicKey,
&i.ChainID,
&i.BlockCreated,
&i.Controller,
&i.Label,
&i.Handle,
&i.IsSubsidiary,
&i.IsValidator,
&i.IsDelegator,
&i.IsAccountable,
)
return i, err
}
const getAccountsByChainID = `-- name: GetAccountsByChainID :many
SELECT id, created_at, updated_at, deleted_at, number, sequence, address, public_key, chain_id, block_created, controller, label, handle, is_subsidiary, is_validator, is_delegator, is_accountable FROM accounts
WHERE chain_id = ? AND deleted_at IS NULL
ORDER BY sequence DESC
`
func (q *Queries) GetAccountsByChainID(ctx context.Context, chainID string) ([]Account, error) {
rows, err := q.db.QueryContext(ctx, getAccountsByChainID, chainID)
if err != nil {
return nil, err
}
defer rows.Close()
var items []Account
for rows.Next() {
var i Account
if err := rows.Scan(
&i.ID,
&i.CreatedAt,
&i.UpdatedAt,
&i.DeletedAt,
&i.Number,
&i.Sequence,
&i.Address,
&i.PublicKey,
&i.ChainID,
&i.BlockCreated,
&i.Controller,
&i.Label,
&i.Handle,
&i.IsSubsidiary,
&i.IsValidator,
&i.IsDelegator,
&i.IsAccountable,
); 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 getAccountsByController = `-- name: GetAccountsByController :many
SELECT id, created_at, updated_at, deleted_at, number, sequence, address, public_key, chain_id, block_created, controller, label, handle, is_subsidiary, is_validator, is_delegator, is_accountable FROM accounts
WHERE controller = ? AND deleted_at IS NULL
ORDER BY created_at DESC
`
func (q *Queries) GetAccountsByController(ctx context.Context, controller string) ([]Account, error) {
rows, err := q.db.QueryContext(ctx, getAccountsByController, controller)
if err != nil {
return nil, err
}
defer rows.Close()
var items []Account
for rows.Next() {
var i Account
if err := rows.Scan(
&i.ID,
&i.CreatedAt,
&i.UpdatedAt,
&i.DeletedAt,
&i.Number,
&i.Sequence,
&i.Address,
&i.PublicKey,
&i.ChainID,
&i.BlockCreated,
&i.Controller,
&i.Label,
&i.Handle,
&i.IsSubsidiary,
&i.IsValidator,
&i.IsDelegator,
&i.IsAccountable,
); 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 getAccountsByHandle = `-- name: GetAccountsByHandle :many
SELECT id, created_at, updated_at, deleted_at, number, sequence, address, public_key, chain_id, block_created, controller, label, handle, is_subsidiary, is_validator, is_delegator, is_accountable FROM accounts
WHERE handle = ? AND deleted_at IS NULL
ORDER BY created_at DESC
`
func (q *Queries) GetAccountsByHandle(ctx context.Context, handle string) ([]Account, error) {
rows, err := q.db.QueryContext(ctx, getAccountsByHandle, handle)
if err != nil {
return nil, err
}
defer rows.Close()
var items []Account
for rows.Next() {
var i Account
if err := rows.Scan(
&i.ID,
&i.CreatedAt,
&i.UpdatedAt,
&i.DeletedAt,
&i.Number,
&i.Sequence,
&i.Address,
&i.PublicKey,
&i.ChainID,
&i.BlockCreated,
&i.Controller,
&i.Label,
&i.Handle,
&i.IsSubsidiary,
&i.IsValidator,
&i.IsDelegator,
&i.IsAccountable,
); 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 getAccountsByLabel = `-- name: GetAccountsByLabel :many
SELECT id, created_at, updated_at, deleted_at, number, sequence, address, public_key, chain_id, block_created, controller, label, handle, is_subsidiary, is_validator, is_delegator, is_accountable FROM accounts
WHERE label = ? AND deleted_at IS NULL
ORDER BY created_at DESC
`
func (q *Queries) GetAccountsByLabel(ctx context.Context, label string) ([]Account, error) {
rows, err := q.db.QueryContext(ctx, getAccountsByLabel, label)
if err != nil {
return nil, err
}
defer rows.Close()
var items []Account
for rows.Next() {
var i Account
if err := rows.Scan(
&i.ID,
&i.CreatedAt,
&i.UpdatedAt,
&i.DeletedAt,
&i.Number,
&i.Sequence,
&i.Address,
&i.PublicKey,
&i.ChainID,
&i.BlockCreated,
&i.Controller,
&i.Label,
&i.Handle,
&i.IsSubsidiary,
&i.IsValidator,
&i.IsDelegator,
&i.IsAccountable,
); 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 getCredentialByID = `-- name: GetCredentialByID :one
SELECT id, created_at, updated_at, deleted_at, handle, credential_id, authenticator_attachment, origin, type, transports FROM credentials
WHERE credential_id = ?
AND deleted_at IS NULL
LIMIT 1
`
func (q *Queries) GetCredentialByID(ctx context.Context, credentialID string) (Credential, error) {
row := q.db.QueryRowContext(ctx, getCredentialByID, credentialID)
var i Credential
err := row.Scan(
&i.ID,
&i.CreatedAt,
&i.UpdatedAt,
&i.DeletedAt,
&i.Handle,
&i.CredentialID,
&i.AuthenticatorAttachment,
&i.Origin,
&i.Type,
&i.Transports,
)
return i, err
}
const getCredentialsByHandle = `-- name: GetCredentialsByHandle :many
SELECT id, created_at, updated_at, deleted_at, handle, credential_id, authenticator_attachment, origin, type, transports FROM credentials
WHERE handle = ?
AND deleted_at IS NULL
`
func (q *Queries) GetCredentialsByHandle(ctx context.Context, handle string) ([]Credential, error) {
rows, err := q.db.QueryContext(ctx, getCredentialsByHandle, handle)
if err != nil {
return nil, err
}
defer rows.Close()
var items []Credential
for rows.Next() {
var i Credential
if err := rows.Scan(
&i.ID,
&i.CreatedAt,
&i.UpdatedAt,
&i.DeletedAt,
&i.Handle,
&i.CredentialID,
&i.AuthenticatorAttachment,
&i.Origin,
&i.Type,
&i.Transports,
); 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 getProfileByAddress = `-- name: GetProfileByAddress :one
SELECT id, created_at, updated_at, deleted_at, address, handle, origin, name FROM profiles
WHERE address = ? AND deleted_at IS NULL
LIMIT 1
`
func (q *Queries) GetProfileByAddress(ctx context.Context, address string) (Profile, error) {
row := q.db.QueryRowContext(ctx, getProfileByAddress, address)
var i Profile
err := row.Scan(
&i.ID,
&i.CreatedAt,
&i.UpdatedAt,
&i.DeletedAt,
&i.Address,
&i.Handle,
&i.Origin,
&i.Name,
)
return i, err
}
const getProfileByHandle = `-- name: GetProfileByHandle :one
SELECT id, created_at, updated_at, deleted_at, address, handle, origin, name FROM profiles
WHERE handle = ?
AND deleted_at IS NULL
LIMIT 1
`
func (q *Queries) GetProfileByHandle(ctx context.Context, handle string) (Profile, error) {
row := q.db.QueryRowContext(ctx, getProfileByHandle, handle)
var i Profile
err := row.Scan(
&i.ID,
&i.CreatedAt,
&i.UpdatedAt,
&i.DeletedAt,
&i.Address,
&i.Handle,
&i.Origin,
&i.Name,
)
return i, err
}
const getProfileByID = `-- name: GetProfileByID :one
SELECT id, created_at, updated_at, deleted_at, address, handle, origin, name FROM profiles
WHERE id = ? AND deleted_at IS NULL
LIMIT 1
`
func (q *Queries) GetProfileByID(ctx context.Context, id string) (Profile, error) {
row := q.db.QueryRowContext(ctx, getProfileByID, id)
var i Profile
err := row.Scan(
&i.ID,
&i.CreatedAt,
&i.UpdatedAt,
&i.DeletedAt,
&i.Address,
&i.Handle,
&i.Origin,
&i.Name,
)
return i, err
}
const getVaultByID = `-- name: GetVaultByID :one
SELECT id, created_at, updated_at, deleted_at, handle, origin, address, cid, config, session_id, redirect_uri FROM vaults
WHERE id = ?
AND deleted_at IS NULL
LIMIT 1
`
func (q *Queries) GetVaultByID(ctx context.Context, id string) (Vault, error) {
row := q.db.QueryRowContext(ctx, getVaultByID, id)
var i Vault
err := row.Scan(
&i.ID,
&i.CreatedAt,
&i.UpdatedAt,
&i.DeletedAt,
&i.Handle,
&i.Origin,
&i.Address,
&i.Cid,
&i.Config,
&i.SessionID,
&i.RedirectUri,
)
return i, err
}
const getVaultConfigByCID = `-- name: GetVaultConfigByCID :one
SELECT id, created_at, updated_at, deleted_at, handle, origin, address, cid, config, session_id, redirect_uri FROM vaults
WHERE cid = ?
AND deleted_at IS NULL
LIMIT 1
`
func (q *Queries) GetVaultConfigByCID(ctx context.Context, cid string) (Vault, error) {
row := q.db.QueryRowContext(ctx, getVaultConfigByCID, cid)
var i Vault
err := row.Scan(
&i.ID,
&i.CreatedAt,
&i.UpdatedAt,
&i.DeletedAt,
&i.Handle,
&i.Origin,
&i.Address,
&i.Cid,
&i.Config,
&i.SessionID,
&i.RedirectUri,
)
return i, err
}
const getVaultRedirectURIBySessionID = `-- name: GetVaultRedirectURIBySessionID :one
SELECT redirect_uri FROM vaults
WHERE session_id = ?
AND deleted_at IS NULL
LIMIT 1
`
func (q *Queries) GetVaultRedirectURIBySessionID(ctx context.Context, sessionID string) (string, error) {
row := q.db.QueryRowContext(ctx, getVaultRedirectURIBySessionID, sessionID)
var redirect_uri string
err := row.Scan(&redirect_uri)
return redirect_uri, err
}
const getVaultsByHandle = `-- name: GetVaultsByHandle :many
SELECT id, created_at, updated_at, deleted_at, handle, origin, address, cid, config, session_id, redirect_uri FROM vaults
WHERE handle = ?
AND deleted_at IS NULL
ORDER BY created_at DESC
`
func (q *Queries) GetVaultsByHandle(ctx context.Context, handle string) ([]Vault, error) {
rows, err := q.db.QueryContext(ctx, getVaultsByHandle, handle)
if err != nil {
return nil, err
}
defer rows.Close()
var items []Vault
for rows.Next() {
var i Vault
if err := rows.Scan(
&i.ID,
&i.CreatedAt,
&i.UpdatedAt,
&i.DeletedAt,
&i.Handle,
&i.Origin,
&i.Address,
&i.Cid,
&i.Config,
&i.SessionID,
&i.RedirectUri,
); 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 insertAccount = `-- name: InsertAccount :one
INSERT INTO accounts (
number,
sequence,
address,
public_key,
chain_id,
block_created,
controller,
label,
is_subsidiary,
is_validator,
is_delegator,
is_accountable
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
RETURNING id, created_at, updated_at, deleted_at, number, sequence, address, public_key, chain_id, block_created, controller, label, handle, is_subsidiary, is_validator, is_delegator, is_accountable
`
type InsertAccountParams struct {
Number int64 `json:"number"`
Sequence int64 `json:"sequence"`
Address string `json:"address"`
PublicKey string `json:"public_key"`
ChainID string `json:"chain_id"`
BlockCreated int64 `json:"block_created"`
Controller string `json:"controller"`
Label string `json:"label"`
IsSubsidiary bool `json:"is_subsidiary"`
IsValidator bool `json:"is_validator"`
IsDelegator bool `json:"is_delegator"`
IsAccountable bool `json:"is_accountable"`
}
// ACCOUNT QUERIES
func (q *Queries) InsertAccount(ctx context.Context, arg InsertAccountParams) (Account, error) {
row := q.db.QueryRowContext(ctx, insertAccount,
arg.Number,
arg.Sequence,
arg.Address,
arg.PublicKey,
arg.ChainID,
arg.BlockCreated,
arg.Controller,
arg.Label,
arg.IsSubsidiary,
arg.IsValidator,
arg.IsDelegator,
arg.IsAccountable,
)
var i Account
err := row.Scan(
&i.ID,
&i.CreatedAt,
&i.UpdatedAt,
&i.DeletedAt,
&i.Number,
&i.Sequence,
&i.Address,
&i.PublicKey,
&i.ChainID,
&i.BlockCreated,
&i.Controller,
&i.Label,
&i.Handle,
&i.IsSubsidiary,
&i.IsValidator,
&i.IsDelegator,
&i.IsAccountable,
)
return i, err
}
const insertCredential = `-- name: InsertCredential :one
INSERT INTO credentials (
handle,
credential_id,
authenticator_attachment,
origin,
type,
transports
) VALUES (?, ?, ?, ?, ?, ?)
RETURNING id, created_at, updated_at, deleted_at, handle, credential_id, authenticator_attachment, origin, type, transports
`
type InsertCredentialParams struct {
Handle string `json:"handle"`
CredentialID string `json:"credential_id"`
AuthenticatorAttachment string `json:"authenticator_attachment"`
Origin string `json:"origin"`
Type string `json:"type"`
Transports string `json:"transports"`
}
// CREDENTIAL QUERIES
func (q *Queries) InsertCredential(ctx context.Context, arg InsertCredentialParams) (Credential, error) {
row := q.db.QueryRowContext(ctx, insertCredential,
arg.Handle,
arg.CredentialID,
arg.AuthenticatorAttachment,
arg.Origin,
arg.Type,
arg.Transports,
)
var i Credential
err := row.Scan(
&i.ID,
&i.CreatedAt,
&i.UpdatedAt,
&i.DeletedAt,
&i.Handle,
&i.CredentialID,
&i.AuthenticatorAttachment,
&i.Origin,
&i.Type,
&i.Transports,
)
return i, err
}
const insertProfile = `-- name: InsertProfile :one
INSERT INTO profiles (
address,
handle,
origin,
name
) VALUES (?, ?, ?, ?)
RETURNING id, created_at, updated_at, deleted_at, address, handle, origin, name
`
type InsertProfileParams struct {
Address string `json:"address"`
Handle string `json:"handle"`
Origin string `json:"origin"`
Name string `json:"name"`
}
// PROFILE QUERIES
func (q *Queries) InsertProfile(ctx context.Context, arg InsertProfileParams) (Profile, error) {
row := q.db.QueryRowContext(ctx, insertProfile,
arg.Address,
arg.Handle,
arg.Origin,
arg.Name,
)
var i Profile
err := row.Scan(
&i.ID,
&i.CreatedAt,
&i.UpdatedAt,
&i.DeletedAt,
&i.Address,
&i.Handle,
&i.Origin,
&i.Name,
)
return i, err
}
const insertVault = `-- name: InsertVault :one
INSERT INTO vaults (
handle,
origin,
address,
cid,
config,
session_id,
redirect_uri
) VALUES (?, ?, ?, ?, ?, ?, ?)
RETURNING id, created_at, updated_at, deleted_at, handle, origin, address, cid, config, session_id, redirect_uri
`
type InsertVaultParams struct {
Handle string `json:"handle"`
Origin string `json:"origin"`
Address string `json:"address"`
Cid string `json:"cid"`
Config string `json:"config"`
SessionID string `json:"session_id"`
RedirectUri string `json:"redirect_uri"`
}
// VAULT QUERIES
func (q *Queries) InsertVault(ctx context.Context, arg InsertVaultParams) (Vault, error) {
row := q.db.QueryRowContext(ctx, insertVault,
arg.Handle,
arg.Origin,
arg.Address,
arg.Cid,
arg.Config,
arg.SessionID,
arg.RedirectUri,
)
var i Vault
err := row.Scan(
&i.ID,
&i.CreatedAt,
&i.UpdatedAt,
&i.DeletedAt,
&i.Handle,
&i.Origin,
&i.Address,
&i.Cid,
&i.Config,
&i.SessionID,
&i.RedirectUri,
)
return i, err
}
const listDelegatorAccounts = `-- name: ListDelegatorAccounts :many
SELECT id, created_at, updated_at, deleted_at, number, sequence, address, public_key, chain_id, block_created, controller, label, handle, is_subsidiary, is_validator, is_delegator, is_accountable FROM accounts
WHERE is_delegator = 1
AND deleted_at IS NULL
ORDER BY created_at DESC
`
func (q *Queries) ListDelegatorAccounts(ctx context.Context) ([]Account, error) {
rows, err := q.db.QueryContext(ctx, listDelegatorAccounts)
if err != nil {
return nil, err
}
defer rows.Close()
var items []Account
for rows.Next() {
var i Account
if err := rows.Scan(
&i.ID,
&i.CreatedAt,
&i.UpdatedAt,
&i.DeletedAt,
&i.Number,
&i.Sequence,
&i.Address,
&i.PublicKey,
&i.ChainID,
&i.BlockCreated,
&i.Controller,
&i.Label,
&i.Handle,
&i.IsSubsidiary,
&i.IsValidator,
&i.IsDelegator,
&i.IsAccountable,
); 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 listProfiles = `-- name: ListProfiles :many
SELECT id, created_at, updated_at, deleted_at, address, handle, origin, name FROM profiles
WHERE deleted_at IS NULL
ORDER BY created_at DESC
LIMIT ? OFFSET ?
`
type ListProfilesParams struct {
Limit int64 `json:"limit"`
Offset int64 `json:"offset"`
}
func (q *Queries) ListProfiles(ctx context.Context, arg ListProfilesParams) ([]Profile, error) {
rows, err := q.db.QueryContext(ctx, listProfiles, arg.Limit, arg.Offset)
if err != nil {
return nil, err
}
defer rows.Close()
var items []Profile
for rows.Next() {
var i Profile
if err := rows.Scan(
&i.ID,
&i.CreatedAt,
&i.UpdatedAt,
&i.DeletedAt,
&i.Address,
&i.Handle,
&i.Origin,
&i.Name,
); 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 listValidatorAccounts = `-- name: ListValidatorAccounts :many
SELECT id, created_at, updated_at, deleted_at, number, sequence, address, public_key, chain_id, block_created, controller, label, handle, is_subsidiary, is_validator, is_delegator, is_accountable FROM accounts
WHERE is_validator = 1
AND deleted_at IS NULL
ORDER BY created_at DESC
`
func (q *Queries) ListValidatorAccounts(ctx context.Context) ([]Account, error) {
rows, err := q.db.QueryContext(ctx, listValidatorAccounts)
if err != nil {
return nil, err
}
defer rows.Close()
var items []Account
for rows.Next() {
var i Account
if err := rows.Scan(
&i.ID,
&i.CreatedAt,
&i.UpdatedAt,
&i.DeletedAt,
&i.Number,
&i.Sequence,
&i.Address,
&i.PublicKey,
&i.ChainID,
&i.BlockCreated,
&i.Controller,
&i.Label,
&i.Handle,
&i.IsSubsidiary,
&i.IsValidator,
&i.IsDelegator,
&i.IsAccountable,
); 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 softDeleteAccount = `-- name: SoftDeleteAccount :exec
UPDATE accounts
SET deleted_at = CURRENT_TIMESTAMP
WHERE id = ?
`
func (q *Queries) SoftDeleteAccount(ctx context.Context, id string) error {
_, err := q.db.ExecContext(ctx, softDeleteAccount, id)
return err
}
const softDeleteCredential = `-- name: SoftDeleteCredential :exec
UPDATE credentials
SET deleted_at = CURRENT_TIMESTAMP
WHERE credential_id = ?
`
func (q *Queries) SoftDeleteCredential(ctx context.Context, credentialID string) error {
_, err := q.db.ExecContext(ctx, softDeleteCredential, credentialID)
return err
}
const softDeleteProfile = `-- name: SoftDeleteProfile :exec
UPDATE profiles
SET deleted_at = CURRENT_TIMESTAMP
WHERE address = ?
`
func (q *Queries) SoftDeleteProfile(ctx context.Context, address string) error {
_, err := q.db.ExecContext(ctx, softDeleteProfile, address)
return err
}
const softDeleteVault = `-- name: SoftDeleteVault :exec
UPDATE vaults
SET deleted_at = CURRENT_TIMESTAMP
WHERE id = ?
`
func (q *Queries) SoftDeleteVault(ctx context.Context, id string) error {
_, err := q.db.ExecContext(ctx, softDeleteVault, id)
return err
}
const updateAccountLabel = `-- name: UpdateAccountLabel :one
UPDATE accounts
SET
label = ?,
updated_at = CURRENT_TIMESTAMP
WHERE id = ?
AND deleted_at IS NULL
RETURNING id, created_at, updated_at, deleted_at, number, sequence, address, public_key, chain_id, block_created, controller, label, handle, is_subsidiary, is_validator, is_delegator, is_accountable
`
type UpdateAccountLabelParams struct {
Label string `json:"label"`
ID string `json:"id"`
}
func (q *Queries) UpdateAccountLabel(ctx context.Context, arg UpdateAccountLabelParams) (Account, error) {
row := q.db.QueryRowContext(ctx, updateAccountLabel, arg.Label, arg.ID)
var i Account
err := row.Scan(
&i.ID,
&i.CreatedAt,
&i.UpdatedAt,
&i.DeletedAt,
&i.Number,
&i.Sequence,
&i.Address,
&i.PublicKey,
&i.ChainID,
&i.BlockCreated,
&i.Controller,
&i.Label,
&i.Handle,
&i.IsSubsidiary,
&i.IsValidator,
&i.IsDelegator,
&i.IsAccountable,
)
return i, err
}
const updateAccountSequence = `-- name: UpdateAccountSequence :one
UPDATE accounts
SET
sequence = ?,
updated_at = CURRENT_TIMESTAMP
WHERE address = ?
AND deleted_at IS NULL
RETURNING id, created_at, updated_at, deleted_at, number, sequence, address, public_key, chain_id, block_created, controller, label, handle, is_subsidiary, is_validator, is_delegator, is_accountable
`
type UpdateAccountSequenceParams struct {
Sequence int64 `json:"sequence"`
Address string `json:"address"`
}
func (q *Queries) UpdateAccountSequence(ctx context.Context, arg UpdateAccountSequenceParams) (Account, error) {
row := q.db.QueryRowContext(ctx, updateAccountSequence, arg.Sequence, arg.Address)
var i Account
err := row.Scan(
&i.ID,
&i.CreatedAt,
&i.UpdatedAt,
&i.DeletedAt,
&i.Number,
&i.Sequence,
&i.Address,
&i.PublicKey,
&i.ChainID,
&i.BlockCreated,
&i.Controller,
&i.Label,
&i.Handle,
&i.IsSubsidiary,
&i.IsValidator,
&i.IsDelegator,
&i.IsAccountable,
)
return i, err
}
const updateProfile = `-- name: UpdateProfile :one
UPDATE profiles
SET
name = ?,
handle = ?,
updated_at = CURRENT_TIMESTAMP
WHERE address = ?
AND deleted_at IS NULL
RETURNING id, created_at, updated_at, deleted_at, address, handle, origin, name
`
type UpdateProfileParams struct {
Name string `json:"name"`
Handle string `json:"handle"`
Address string `json:"address"`
}
func (q *Queries) UpdateProfile(ctx context.Context, arg UpdateProfileParams) (Profile, error) {
row := q.db.QueryRowContext(ctx, updateProfile, arg.Name, arg.Handle, arg.Address)
var i Profile
err := row.Scan(
&i.ID,
&i.CreatedAt,
&i.UpdatedAt,
&i.DeletedAt,
&i.Address,
&i.Handle,
&i.Origin,
&i.Name,
)
return i, err
}
const updateVault = `-- name: UpdateVault :one
UPDATE vaults
SET
config = ?,
updated_at = CURRENT_TIMESTAMP
WHERE id = ?
AND deleted_at IS NULL
RETURNING id, created_at, updated_at, deleted_at, handle, origin, address, cid, config, session_id, redirect_uri
`
type UpdateVaultParams struct {
Config string `json:"config"`
ID string `json:"id"`
}
func (q *Queries) UpdateVault(ctx context.Context, arg UpdateVaultParams) (Vault, error) {
row := q.db.QueryRowContext(ctx, updateVault, arg.Config, arg.ID)
var i Vault
err := row.Scan(
&i.ID,
&i.CreatedAt,
&i.UpdatedAt,
&i.DeletedAt,
&i.Handle,
&i.Origin,
&i.Address,
&i.Cid,
&i.Config,
&i.SessionID,
&i.RedirectUri,
)
return i, err
}