This repository has been archived on 2022-05-25. You can view files and clone it, but cannot push or open issues or pull requests.
elon-eats-my-tweets/generated/store/queries.sql.go

129 lines
3.1 KiB
Go
Raw Normal View History

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.13.0
// source: queries.sql
package store
import (
"context"
2022-05-24 19:20:28 +00:00
"database/sql"
"time"
)
const createUser = `-- name: CreateUser :one
2022-05-20 22:34:20 +00:00
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 twitter_id, username, name, access_token, refresh_token, delete_tweets_enabled, delete_tweets_num_per_iteration, created_at, updated_at
`
type CreateUserParams struct {
TwitterID int64
2022-05-20 22:34:20 +00:00
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,
2022-05-20 22:34:20 +00:00
arg.RefreshToken,
arg.CreatedAt,
arg.UpdatedAt,
)
var i User
err := row.Scan(
&i.TwitterID,
&i.Username,
&i.Name,
&i.AccessToken,
&i.RefreshToken,
&i.DeleteTweetsEnabled,
&i.DeleteTweetsNumPerIteration,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}
2022-05-20 22:34:20 +00:00
2022-05-24 19:20:28 +00:00
const getLastElonTweet = `-- name: GetLastElonTweet :one
SELECT twitter_id, text, posted_at, processed_at, created_at, updated_at from elon_tweets ORDER BY twitter_id DESC LIMIT 1
2022-05-24 19:20:28 +00:00
`
func (q *Queries) GetLastElonTweet(ctx context.Context) (ElonTweet, error) {
row := q.db.QueryRow(ctx, getLastElonTweet)
var i ElonTweet
err := row.Scan(
&i.TwitterID,
&i.Text,
&i.PostedAt,
&i.ProcessedAt,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}
2022-05-20 22:34:20 +00:00
const getUserByTwitterID = `-- name: GetUserByTwitterID :one
SELECT 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
2022-05-20 22:34:20 +00:00
`
func (q *Queries) GetUserByTwitterID(ctx context.Context, twitterID int64) (User, error) {
2022-05-20 22:34:20 +00:00
row := q.db.QueryRow(ctx, getUserByTwitterID, twitterID)
var i User
err := row.Scan(
&i.TwitterID,
&i.Username,
&i.Name,
&i.AccessToken,
&i.RefreshToken,
&i.DeleteTweetsEnabled,
&i.DeleteTweetsNumPerIteration,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}
2022-05-24 19:20:28 +00:00
const upsertElonTweet = `-- name: UpsertElonTweet :one
INSERT INTO elon_tweets (twitter_id, text, posted_at, processed_at, created_at, updated_at)
VALUES ($1, $2, $3, $4, NOW(), NOW())
ON CONFLICT (twitter_id) DO NOTHING
RETURNING twitter_id, text, posted_at, processed_at, created_at, updated_at
2022-05-24 19:20:28 +00:00
`
type UpsertElonTweetParams struct {
TwitterID int64
Text string
PostedAt time.Time
ProcessedAt sql.NullTime
}
func (q *Queries) UpsertElonTweet(ctx context.Context, arg UpsertElonTweetParams) (ElonTweet, error) {
row := q.db.QueryRow(ctx, upsertElonTweet,
arg.TwitterID,
arg.Text,
arg.PostedAt,
arg.ProcessedAt,
)
var i ElonTweet
err := row.Scan(
&i.TwitterID,
&i.Text,
&i.PostedAt,
&i.ProcessedAt,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}