-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: user followers is now nested on user document (#88)
- Loading branch information
1 parent
117fae7
commit 2f2c683
Showing
6 changed files
with
30 additions
and
31 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 |
---|---|---|
@@ -1,6 +1,11 @@ | ||
/* N1QL query to prepend a username to the user's following. */ | ||
|
||
UPDATE `bucket_name` | ||
USE KEYS $user | ||
USE KEYS LOWER($user) | ||
SET `following` = ARRAY_PREPEND({"username": $username, "ts": $ts}, `following`) | ||
WHERE NOT ANY item IN `following` SATISFIES item.username = $username END; | ||
|
||
UPDATE `bucket_name` | ||
USE KEYS LOWER($username) | ||
SET `followers` = ARRAY_PREPEND({"username": $user, "ts": $ts}, `followers`) | ||
WHERE NOT ANY item IN `followers` SATISFIES item.username = $user END; |
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 |
---|---|---|
@@ -1,7 +1,13 @@ | ||
/* N1QL query to remove a user from a user's following. */ | ||
|
||
UPDATE `bucket_name` | ||
USE KEYS $user | ||
USE KEYS LOWER($user) | ||
SET `following` = ARRAY item FOR item IN `following` | ||
WHEN item.username != $username END | ||
WHERE ANY item IN `following` SATISFIES item.username = $username END; | ||
|
||
UPDATE `bucket_name` | ||
USE KEYS LOWER($username) | ||
SET `followers` = ARRAY item FOR item IN `followers` | ||
WHEN item.username != $user END | ||
WHERE ANY item IN `followers` SATISFIES item.username = $user END; |
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
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