matrix-bridge-meshtastic/db/meshtastic_nodes.sql.go

62 lines
1.5 KiB
Go
Raw Normal View History

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.20.0
// source: meshtastic_nodes.sql
package db
import (
"context"
"database/sql"
)
const meshtasticNodeGet = `-- name: MeshtasticNodeGet :one
SELECT id, node_num, meshtastic_id, long_name, short_name, hw_model, public_key, matrix_id FROM meshtastic_nodes WHERE node_num = ? LIMIT 1
`
func (q *Queries) MeshtasticNodeGet(ctx context.Context, nodeNum int64) (MeshtasticNode, error) {
row := q.db.QueryRowContext(ctx, meshtasticNodeGet, nodeNum)
var i MeshtasticNode
err := row.Scan(
&i.ID,
&i.NodeNum,
&i.MeshtasticID,
&i.LongName,
&i.ShortName,
&i.HwModel,
&i.PublicKey,
&i.MatrixID,
)
return i, err
}
const meshtasticNodeUpdate = `-- name: MeshtasticNodeUpdate :exec
INSERT INTO meshtastic_nodes (node_num, meshtastic_id, long_name, short_name, hw_model, public_key) VALUES (?, ?, ?, ?, ?, ?) ON CONFLICT (node_num) DO UPDATE SET
meshtastic_id = excluded.meshtastic_id,
long_name = excluded.long_name,
short_name = excluded.short_name,
hw_model = excluded.hw_model,
public_key = excluded.public_key
`
type MeshtasticNodeUpdateParams struct {
NodeNum int64
MeshtasticID string
LongName sql.NullString
ShortName sql.NullString
HwModel sql.NullString
PublicKey []byte
}
func (q *Queries) MeshtasticNodeUpdate(ctx context.Context, arg MeshtasticNodeUpdateParams) error {
_, err := q.db.ExecContext(ctx, meshtasticNodeUpdate,
arg.NodeNum,
arg.MeshtasticID,
arg.LongName,
arg.ShortName,
arg.HwModel,
arg.PublicKey,
)
return err
}