2022-05-20 20:57:45 +00:00
|
|
|
-- 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
|
2022-05-20 20:57:45 +00:00
|
|
|
RETURNING *;
|
2022-05-20 22:34:20 +00:00
|
|
|
|
|
|
|
-- name: GetUserByTwitterID :one
|
|
|
|
SELECT * FROM users WHERE twitter_id = $1;
|
2022-05-24 19:20:28 +00:00
|
|
|
|
|
|
|
-- name: GetLastElonTweet :one
|
|
|
|
SELECT * from elon_tweets ORDER BY twitter_id DESC LIMIT 1;
|
|
|
|
|
|
|
|
-- 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 *;
|