79 lines
1.9 KiB
Go
79 lines
1.9 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.13.0
|
|
// source: queries.sql
|
|
|
|
package store
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
)
|
|
|
|
const createUser = `-- name: CreateUser :one
|
|
INSERT INTO users (twitter_id, username, name, access_token, refresh_token, created_at, updated_at)
|
|
VALUES ($1, $2, $3, $4, $5, $6, $7)
|
|
ON CONFLICT (twitter_id)
|
|
DO
|
|
UPDATE SET access_token = EXCLUDED.access_token, refresh_token = EXCLUDED.refresh_token, username = EXCLUDED.username, name = EXCLUDED.name, updated_at = EXCLUDED.updated_at
|
|
RETURNING id, twitter_id, username, name, access_token, refresh_token, delete_tweets_enabled, delete_tweets_num_per_iteration, created_at, updated_at
|
|
`
|
|
|
|
type CreateUserParams struct {
|
|
TwitterID string
|
|
Username string
|
|
Name string
|
|
AccessToken string
|
|
RefreshToken string
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
}
|
|
|
|
func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (User, error) {
|
|
row := q.db.QueryRow(ctx, createUser,
|
|
arg.TwitterID,
|
|
arg.Username,
|
|
arg.Name,
|
|
arg.AccessToken,
|
|
arg.RefreshToken,
|
|
arg.CreatedAt,
|
|
arg.UpdatedAt,
|
|
)
|
|
var i User
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.TwitterID,
|
|
&i.Username,
|
|
&i.Name,
|
|
&i.AccessToken,
|
|
&i.RefreshToken,
|
|
&i.DeleteTweetsEnabled,
|
|
&i.DeleteTweetsNumPerIteration,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getUserByTwitterID = `-- name: GetUserByTwitterID :one
|
|
SELECT id, twitter_id, username, name, access_token, refresh_token, delete_tweets_enabled, delete_tweets_num_per_iteration, created_at, updated_at FROM users WHERE twitter_id = $1
|
|
`
|
|
|
|
func (q *Queries) GetUserByTwitterID(ctx context.Context, twitterID string) (User, error) {
|
|
row := q.db.QueryRow(ctx, getUserByTwitterID, twitterID)
|
|
var i User
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.TwitterID,
|
|
&i.Username,
|
|
&i.Name,
|
|
&i.AccessToken,
|
|
&i.RefreshToken,
|
|
&i.DeleteTweetsEnabled,
|
|
&i.DeleteTweetsNumPerIteration,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|