Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed a bug where plaintexts were ordered by earliest first #2

Merged
merged 1 commit into from
Jul 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions src/server/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,39 +109,34 @@ const bootstrap = `
tags JSONB
);
`

const selectCiphertexts = `
SELECT *
FROM ${tableName}
WHERE plaintext IS NULL
ORDER BY decryptable_at ASC
LIMIT $1;
`

const selectPlaintexts = `
SELECT *
FROM ${tableName}
WHERE plaintext IS NOT NULL
ORDER BY decryptable_at ASC
ORDER BY decryptable_at DESC
LIMIT $1;
`

const selectSingle = `
SELECT *
FROM uploads
WHERE id = $1
LIMIT 1;
`

const insertCiphertext = `
INSERT INTO ${tableName} (created_at, decryptable_at, ciphertext, tags) VALUES($1, $2, $3, $4) RETURNING *
`
const updatePlaintext = `
UPDATE ${tableName} SET plaintext = $2 WHERE id = $1
`

const selectTags = `
SELECT *
FROM uploads
WHERE tags @> $1::jsonb;
`
`