-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e8983f2
commit ab76428
Showing
4 changed files
with
198 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -149,15 +149,11 @@ This is equivalent to: | |
```javascript | ||
async function getUsers() { | ||
await database.query(sql` | ||
SELECT users.email, users.date_of_birth FROM users | ||
INNER JOIN ( | ||
SELECT email, date_of_birth FROM users | ||
WHERE (email, favorite_color) IN ( | ||
SELECT | ||
UNNEST(${[`[email protected]`, `[email protected]`]}::TEXT[]) AS email, | ||
UNNEST(${[`red`, `blue`]}::TEXT[]) AS favorite_color | ||
) AS bulk_query | ||
ON ( | ||
users.email=bulk_query.email | ||
AND users.color=bulk_query.color | ||
UNNEST(${['[email protected]', '[email protected]']}::TEXT[]), | ||
UNNEST(${['red', 'blue']}::TEXT[]) | ||
) | ||
ORDER BY email ASC | ||
LIMIT 100 | ||
|
@@ -216,9 +212,9 @@ async function updateFavoriteColors() { | |
FROM | ||
( | ||
SELECT | ||
UNNEST(${[`[email protected]`, `[email protected]`]}::TEXT[]) | ||
UNNEST(${['[email protected]', '[email protected]']}::TEXT[]) | ||
AS email, | ||
UNNEST(${[`indigo`, `orange`]}::TEXT[]) | ||
UNNEST(${['indigo', 'orange']}::TEXT[]) | ||
AS updated_value_of_favorite_color | ||
) AS bulk_query | ||
WHERE | ||
|
@@ -271,16 +267,10 @@ This is equivalent to: | |
async function getUsers() { | ||
await database.query(sql` | ||
DELETE FROM users | ||
WHERE EXISTS( | ||
SELECT * | ||
FROM | ||
( | ||
UNNEST(${[`[email protected]`, `[email protected]`]}::TEXT[]) AS email, | ||
UNNEST(${[`red`, `blue`]}::TEXT[]) AS favorite_color | ||
) AS bulk_query | ||
WHERE | ||
users.email=bulk_query.email | ||
AND users.color=bulk_query.color | ||
WHERE (email, favorite_color) IN ( | ||
SELECT | ||
UNNEST(${['[email protected]', '[email protected]']}::TEXT[]), | ||
UNNEST(${['red', 'blue']}::TEXT[]) | ||
) | ||
`); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.